r7753@Thesaurus: rabbit | 2009-09-29 13:45:02 +0200
[p5sagit/Class-Accessor-Grouped.git] / README
1 NAME
2     Class::Accessor::Grouped - Lets you build groups of accessors
3
4 SYNOPSIS
5 DESCRIPTION
6     This class lets you build groups of accessors that will call different
7     getters and setters.
8
9 METHODS
10   mk_group_accessors
11     Arguments: $group, @fieldspec
12         Returns: none
13
14     Creates a set of accessors in a given group.
15
16     $group is the name of the accessor group for the generated accessors;
17     they will call get_$group($field) on get and set_$group($field, $value)
18     on set.
19
20     If you want to mimic Class::Accessor's mk_accessors $group has to be
21     'simple' to tell Class::Accessor::Grouped to use its own get_simple and
22     set_simple methods.
23
24     @fieldspec is a list of field/accessor names; if a fieldspec is a scalar
25     this is used as both field and accessor name, if a listref it is
26     expected to be of the form [ $accessor, $field ].
27
28   mk_group_ro_accessors
29     Arguments: $group, @fieldspec
30         Returns: none
31
32     Creates a set of read only accessors in a given group. Identical to
33     <L:/mk_group_accessors> but accessors will throw an error if passed a
34     value rather than setting the value.
35
36   mk_group_wo_accessors
37     Arguments: $group, @fieldspec
38         Returns: none
39
40     Creates a set of write only accessors in a given group. Identical to
41     <L:/mk_group_accessors> but accessors will throw an error if not passed
42     a value rather than getting the value.
43
44   make_group_accessor
45     Arguments: $group, $field
46         Returns: $sub (\CODE)
47
48     Returns a single accessor in a given group; called by mk_group_accessors
49     for each entry in @fieldspec.
50
51   make_group_ro_accessor
52     Arguments: $group, $field
53         Returns: $sub (\CODE)
54
55     Returns a single read-only accessor in a given group; called by
56     mk_group_ro_accessors for each entry in @fieldspec.
57
58   make_group_wo_accessor
59     Arguments: $group, $field
60         Returns: $sub (\CODE)
61
62     Returns a single write-only accessor in a given group; called by
63     mk_group_wo_accessors for each entry in @fieldspec.
64
65   get_simple
66     Arguments: $field
67         Returns: $value
68
69     Simple getter for hash-based objects which returns the value for the
70     field name passed as an argument.
71
72   set_simple
73     Arguments: $field, $new_value
74         Returns: $new_value
75
76     Simple setter for hash-based objects which sets and then returns the
77     value for the field name passed as an argument.
78
79   get_inherited
80     Arguments: $field
81         Returns: $value
82
83     Simple getter for Classes and hash-based objects which returns the value
84     for the field name passed as an argument. This behaves much like
85     Class::Data::Accessor where the field can be set in a base class,
86     inherited and changed in subclasses, and inherited and changed for
87     object instances.
88
89   set_inherited
90     Arguments: $field, $new_value
91         Returns: $new_value
92
93     Simple setter for Classes and hash-based objects which sets and then
94     returns the value for the field name passed as an argument. When called
95     on a hash-based object it will set the appropriate hash key value. When
96     called on a class, it will set a class level variable.
97
98     Note:: This method will die if you try to set an object variable on a
99     non hash-based object.
100
101   get_component_class
102     Arguments: $field
103         Returns: $value
104
105     Gets the value of the specified component class.
106
107         __PACKAGE__->mk_group_accessors('component_class' => 'result_class');
108
109         $self->result_class->method();
110
111         ## same as
112         $self->get_component_class('result_class')->method();
113
114   set_component_class
115     Arguments: $field, $class
116         Returns: $new_value
117
118     Inherited accessor that automatically loads the specified class before
119     setting it. This method will die if the specified class could not be
120     loaded.
121
122         __PACKAGE__->mk_group_accessors('component_class' => 'result_class');
123         __PACKAGE__->result_class('MyClass');
124
125         $self->result_class->method();
126
127   get_super_paths
128     Returns a list of 'parent' or 'super' class names that the current class
129     inherited from.
130
131 AUTHORS
132     Matt S. Trout <mst@shadowcatsystems.co.uk> Christopher H. Laco
133     <claco@chrislaco.com>
134
135     With contributions from:
136
137     Guillermo Roditi <groditi@cpan.org>
138
139 LICENSE
140     You may distribute this code under the same terms as Perl itself.
141