1User::Identity::Item(3)User Contributed Perl DocumentatioUnser::Identity::Item(3)
2
3
4

NAME

6       User::Identity::Item - general base class for User::Identity
7

SYNOPSIS

DESCRIPTION

10       The "User::Identity::Item" base class is extended into useful modules:
11       it has no use by its own.
12

METHODS

14       Constructors
15
16       User::Identity::Item->new([NAME], OPTIONS)
17
18        Option     --Defined in     --Default
19        description                   undef
20        name                          <required>
21        parent                        undef
22
23           . description STRING
24
25               Free format description on the collected item.
26
27           . name STRING
28
29               A simple name for this item.  Try to give a useful name in the
30               context of the item time.  Each time when you lookup items, you
31               need to specify this name, so it should be unique and not to
32               hard to handle in your program.  For instance, when a person is
33               addressed, you usually will give him/her this a nickname.
34
35           . parent OBJECT
36
37               The encapsulating object: the object which collects this one.
38
39       Attributes
40
41       $obj->description
42
43           Free format description on this item.  Please do not add any sig‐
44           nificance to the content of this field: if you are in need for an
45           extra attribute, please contact the author of the module to imple‐
46           ment it, or extend the object to suit your needs.
47
48       $obj->name([NEWNAME])
49
50           The name of this item.  Names are unique within a collection... a
51           second object with the same name within any collection will destroy
52           the already existing object with that name.
53
54           Changing the name of an item is quite dangerous.  You probably want
55           to call User::Identity::Collection::renameRole() instead.
56
57       Collections
58
59       $obj->add(COLLECTION, ROLE)
60
61           The ROLE is added to the COLLECTION.  The COLLECTION is the name of
62           a collection, which will be created automatically with addCollec‐
63           tion() if needed.  The COLLECTION can also be specified as existing
64           collection object.
65
66           The ROLE is anything what is acceptable to User::Identity::Collec‐
67           tion::addRole() of the collection at hand, and is returned.  ROLE
68           typically is a list of parameters for one role, or a reference to
69           an array containing these values.
70
71           Example:
72
73            my $ui   = User::Identity->new(...);
74            my $home = $ui->add(location => [home => street => '27 Roadstreet', ...] );
75            my $work = $ui->add(location => work, tel => '+31-2231-342-13', ... );
76
77            my $travel = User::Identity::Location->new(travel => ...);
78            $ui->add(location => $travel);
79
80            my $system = User::Identity::Collection::System->new(...);
81            $ui->add($system => 'localhost');
82
83       $obj->addCollection(OBJECT ⎪ ([TYPE], OPTIONS))
84
85           Add a new collection of roles to an item.  This can be achieved in
86           two ways: either create an User::Identity::Collection OBJECT your‐
87           self and then pass that to this method, or supply all the OPTIONS
88           needed to create such an object and it will be created for you.
89           The object which is added is returned, and can be used for many
90           methods directly.
91
92           For OPTIONS, see the specific type of collection.  Additional
93           options are listed below.
94
95            Option--Defined in--Default
96            type                <required>
97
98           . type STRING⎪CLASS
99
100               The nickname of a collection class or the CLASS name itself of
101               the object to be created.  Required if an object has to be cre‐
102               ated.  Predefined type nicknames are "email", "system", and
103               "location".
104
105           Example:
106
107            my $me   = User::Identity->new(...);
108            my $locs = User::Identity::Collection::Locations->new();
109            $me->addCollection($locs);
110
111            my $email = $me->addCollection(type => 'email');
112            my $email = $me->addCollection('email');
113
114       $obj->collection(NAME)
115
116           In scalar context the collection object with the NAME is returned.
117           In list context, all the roles within the collection are returned.
118
119           Example:
120
121            my @roles = $me->collection('email');        # list of collected items
122            my @roles = $me->collection('email')->roles; # same of collected items
123            my $coll  = $me->collection('email');        # a User::Identity::Collection
124
125       $obj->find(COLLECTION, ROLE)
126
127           Returns the object with the specified ROLE within the named collec‐
128           tion.  The collection can be specified as name or object.
129
130           Example:
131
132            my $role  = $me->find(location => 'work');       # one location
133            my $role  = $me->collection('location')->find('work'); # same
134
135            my $email = $me->addCollection('email');
136            $me->find($email => 'work');
137            $email->find('work');   # same
138
139       $obj->parent([PARENT])
140
141           Returns the parent of an Item (the enclosing item).  This may
142           return "undef" if the object is stand-alone.
143
144       $obj->removeCollection(OBJECT⎪NAME)
145
146       $obj->type
147
148       User::Identity::Item->type
149
150           Returns a nice symbolic name for the type.
151
152       $obj->user
153
154           Go from this object to its parent, to its parent, and so on, until
155           a User::Identity is found or the top of the object tree has been
156           reached.
157
158           Example:
159
160            print $email->user->fullName;
161

DIAGNOSTICS

163       Error: $object is not a collection.
164
165       The first argument is an object, but not of a class which extends
166       User::Identity::Collection.
167
168       Error: Cannot load collection module for $type ($class).
169
170       Either the specified $type does not exist, or that module named $class
171       returns compilation errors.  If the type as specified in the warning is
172       not the name of a package, you specified a nickname which was not
173       defined.  Maybe you forgot the 'require' the package which defines the
174       nickname.
175
176       Error: Creation of a collection via $class failed.
177
178       The $class did compile, but it was not possible to create an object of
179       that class using the options you specified.
180
181       Error: Don't know what type of collection you want to add.
182
183       If you add a collection, it must either by a collection object or a
184       list of options which can be used to create a collection object.  In
185       the latter case, the type of collection must be specified.
186
187       Error: Each item requires a name
188
189       You have to specify a name for each item.  These names need to be
190       unique within one collection, but feel free to give the same name to an
191       e-mail address and a location.
192
193       Warning: No collection $name
194
195       The collection with $name does not exist and can not be created.
196
197       Warning: Unknown option $name for a $class
198
199       One used option is not defined.  Check the manual page of the class to
200       see which options are accepted.
201
202       Warning: Unknown options @names for a $class
203
204       More than one option is not defined.
205

SEE ALSO

207       This module is part of User-Identity distribution version 0.91, built
208       on January 08, 2007. Website: http://perl.overmeer.net/userid/
209

LICENSE

211       Copyrights 2003,2004,2007 by Mark Overmeer <perl@overmeer.net>.For
212       other contributors see Changes.
213
214       This program is free software; you can redistribute it and/or modify it
215       under the same terms as Perl itself.  See
216       http://www.perl.com/perl/misc/Artistic.html
217
218
219
220perl v5.8.8                       2007-01-08           User::Identity::Item(3)
Impressum