Mango::Object - Base class used for Mango result objects.
package Mango::User; use base qw/Mango::Object/;
Mango::Object is the base class for all result objects in Mango. It provides common methods exposed by all results like "id", "created", "updated", "update", etc.
Creates a new object, assigned each name/value pair to columns of the same name. In addition to using the column names, the following special keys are available:
This is a hash containing the meta data for the object being created:
my $object = Mango::Object->new({ col1 => 'foo', col2 => 12, meta => { provider => $provider } }); $object->meta->provider->delete(...);
See "meta_class".
Returns the date and time in UTC the object was created as a DateTime object.
print $object->created;
Deletes the current object from the provider.
Returns the value of the specified column from "data".
print $object->get_column('foo'); # same as $object->foo;
Returns a hash of all columns as name/value pairs.
my %columns = $object->get_columns;
Returns id of the current object.
print $object->id;
Returns the meta information for the current object. The default meta class is Mango::Object::Meta.
my $provider = $object->meta->provider;
Gets/sets the class to be used to handle meta data for objects.
Mango::Object->meta_class('MyMetaClass');
This can also be set on a per object basis in the constructor:
my $object = Mango::Object->new({ meta => {...}, meta_class => 'MyMetaClass' });
Sets the value of the specified column.
$object->set_column('foo', 'bar'); # same as $object->foo('bar');
Saves any changes made to the object back to the provider.
$object->foo(2); $object->update;
Whenever "update" is called, "updated" is automatically set to the current time in UTC.
Returns the date and time in UTC the object was last updated as a DateTime object.
print $object->updated;
Gets the current class for the specified component name.
my $class = $self->get_component_class('result_class');
There is no good reason to use this. Use the specific class accessors instead.
Sets the current class for the specified component name.
$self->set_component_class('result_class', 'MyItemClass');
A Mango::Exception exception will be thrown if the specified class can not be loaded.
Mango::Object::Meta, Mango::Provider
Christopher H. Laco CPAN ID: CLACO claco@chrislaco.com http://today.icantfocus.com/blog/
To install Mango, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mango
CPAN shell
perl -MCPAN -e shell install Mango
For more information on module installation, please visit the detailed CPAN module installation guide.