Class::AutoDB::Registration - One registration for Class::AutoDB::Registry
This is a helper class for Class::AutoDB::Registry which represents one entry in a registry.
use Class::AutoDB::Registration; my $registration=new Class::AutoDB::Registration (-class=>'Class::Person', -collection=>'Person', -keys=>qq(name string, dob integer, significant_other object, friends list(object)), -transients=>[qw(age)], -auto_gets=>[qw(significant_other)]); # Set the object's attributes my $collection=$registration->collection; my $class=$registration->class; my $keys=$registration->keys; my $transients=>$registration->transients; my $auto_gets=>$registration->auto_gets;
This class represents essentially raw registration information submitted via the 'register' method of Class::AutoDB::Registry. This class parses the 'keys' parameter, but does not verify that attribute names and data types are valid. This class does not talk to the database.
The 'keys' parameter consists of attribute, data type pairs, or can also be an ARRAY ref of attribute names. In the latter case the data type of each attribute is assumed to be 'string'.
Name |
Description |
Priority/When |
---|---|---|
|
|
|
Title |
new |
|
Usage |
my $registration=new Class::AutoDB::Registration (-class=>'Person', -collection=>'Person', -keys=>qq(name string, dob integer, significant_other object,friends list(object)), -transients=>[qw(age)], -auto_gets=>[qw(significant_other)]); |
|
Function |
Constructor. |
|
Args |
-class |
Name of class being registered |
-collection |
Name of collection being registered or ARRAY ref of names |
|
-collections |
Synonym for -collection |
|
-keys |
Search keys for collection. Can be string of comma separated attribute and data type pairs, or ARRAY ref of attributes in which case the type is assumed to be 'string'. |
|
-transients |
ARRAY ref of attributes that will not be stored. |
|
-auto_gets |
ARRAY ref of attributes that should be automatically retrieved when this object is retrieved. |
|
Returns |
Registration object |
These are methods for getting and setting the values of simple attributes. Methods have the same name as the attribute. Some of these should be read-only (more precisely, should only be written by code internal to the object), but this is not enforced.
To get the value of attribute xxx, just say
$xxx=$object->xxx;
To set a scalar attribute, say
$object->xxx($new_value);
To clear it, say
$object->xxx(undef);
Attribute |
class |
Function |
Name of class being registered |
Access |
Read-write |
Attribute |
collection |
Function |
Name of collection being registered |
Returns |
In scalar context, the name (if there's just one) or the first name (if there are several). In array context, list of names. |
Access |
Read-write |
Attribute |
collections |
Function |
Synonym for collection with slightly different return types. |
Returns |
In scalar context, ARRAY ref of names. In array context, ARRAY of names. |
Access |
Read-write |
Attribute |
transients |
Function |
Attributes that are not stored. |
Returns |
In scalar context, ARRAY ref of attribute names. In array context, ARRAY of attribute names. |
Access |
Read-write |
Attribute |
auto_gets |
Function |
Attributes that are automatically retrieved when this object is retrieved |
Returns |
In scalar context, ARRAY ref of attribute names. In array context, ARRAY of attribute names. |
Access |
Read-write |
Title |
keys |
|
Usage |
my %keys=$table->keys |
|
my $keys=$table->keys |
||
my %keys=$table->keys($keys) |
||
my $keys=$table->keys($keys) |
||
Function |
Get or set keys registered for this table. Returns HASH or HASH ref of key=>type pairs depending on context. |
|
Args |
$keys |
Search keys for collection. Can be string of comma separated attribute and data type pairs, or ARRAY ref of attributes in which case the type is assumed to be 'string'. |
Returns |
HASH or HASH ref depending on context |