Object::Relation::Meta - Object::Relation class automation, introspection, and data validation
package MyThingy; use strict; BEGIN { my $cm = Object::Relation::Meta->new( key => 'thingy', plural_key => 'thingies', name => 'Thingy', plural_name => 'Thingies', ); $cm->build; }
This class inherits from Class::Meta to provide class automation, introspection, and data validation for Object::Relation classes. It overrides the behavior of Class::Meta to specify the use of the Object::Relation::Meta::Class subclass in place of Class::Meta::Class.
Any class created with Object::Relation::Meta will automatically have Object::Relation::Base pushed onto its @ISA array unless it already inherits from Object::Relation::Base.
@ISA
This class supports the dynamic loading of extra methods specifically designed to be used with particular Object::Relation data store implementations. This is so that the store APIs can easily dispatch to attribute objects, class objects, and data types to get data-store specific metadata without having to do extra work themselves. Data store implementors needing store-specific metadata methods should add them as necessary to the import() methods of Object::Relation::Meta::Class, Object::Relation::Meta::Attribute, and/or/ Object::Relation::Meta::Type
import()
In general, however, Object::Relation users will not need to worry about loading data-store specific APIs, as the data stores will load them themselves. And since the methods should either be protected or otherwise transparent, no one else should use them, anyway.
As of this writing, only a single data-store specific API label is supported:
use Object::Relation::Meta ':with_dbstore_api';
More may be added in the future.
my $cm = Object::Relation::Meta->new(%init);
Overrides the parent Class::Meta constructor in order to specify that the class class be Object::Relation::Meta::Classl, the attribute class be Object::Relation::Meta::Attribute, and that the method class be Object::Relation::Meta::Method. It also forces the key parameter to default to the last part of the package name, e.g., the key for the class My::Big::Fat::Cat would be "cat". This is to override Class::Meta's default of using the full class name for the key.
key
In addition to the parameters supported by Class::Meta->new, Object::Relation::Meta->new supports these extra attributes:
Class::Meta->new
Object::Relation::Meta->new
The pluralized form of the key parameter. For example, if the key is "thingy", the plural key would be "thingies". If not defined, Lingua::EN::Inflect will be used to generate a plural key.
The pluralized form of the name parameter. For example, if the name is "Thingy", the plural key would be "Thingies". If not defined, Lingua::EN::Inflect will be used to generate a plural name.
name
This attribute is the name of an attribute or array reference of names of the attributes to use when sorting a list of objects of the class. If sort_by is not specified, it defaults to the first attribute declared after the uuid and state attributes.
sort_by
uuid
state
This attribute specifies a single Object::Relation class name that the class extends. Extension is similar to inheritance, only extended class objects have their own UUIDs and states, and there can be multiple extending objects for a single extended object (think one person acting as several users).
my $class_class = Object::Relation::Meta->class_class; Object::Relation::Meta->class_class($class_class);
The subclass or Class::Meta::Class that will be used to represent class objects. The value of this class attribute is only used at startup time when classes are loaded, so if you want to change it form the default, which is "Object::Relation::Meta::Class", do it before you load any Object::Relation classes.
my $attribute_class = Object::Relation::Meta->attribute_class; Object::Relation::Meta->attribute_class($attribute_class);
The subclass or Class::Meta::Attribute that will be used to represent attribute objects. The value of this class attribute is only used at startup time when classes are loaded, so if you want to change it form the default, which is "Object::Relation::Meta::Attribute", do it before you load any Object::Relation classes.
my $method_class = Object::Relation::Meta->method_class; Object::Relation::Meta->method_class($method_class);
The subclass or Class::Meta::Method that will be used to represent method objects. The value of this class method is only used at startup time when classes are loaded, so if you want to change it form the default, which is "Object::Relation::Meta::Method", do it before you load any Object::Relation classes.
my $class = Object::Relation::Meta->for_key($key);
This method overrides the implementation inherited from Class::Meta to throw an exception no class object exists for the key passed as its sole argument. To use for_key() without getting an exception, call Class::Meta->for_key(), instead.
for_key()
Class::Meta->for_key()
my $attribute = Object::Relation::Meta->attr_for_key('foo.bar');
This method returns a Object::Relation::Meta::Attribute object for a given class key and attribute. The class key and attribute name are separated by a dot (".") in the argument. In this above example, the attribute "bar" would be returned for the class with the key "foo".
Copyright (c) 2004-2006 Kineticode, Inc. <info@obj_relode.com>
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Object::Relation, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Object::Relation
CPAN shell
perl -MCPAN -e shell install Object::Relation
For more information on module installation, please visit the detailed CPAN module installation guide.