Handel::Storage::Result - Generic result object returned by storage operations
use Handel::Storage::DBIC::Cart; my $storage = Handel::Storage::DBIC::Cart->new; my $result = $storage->create({ shopper => '11111111-1111-1111-1111-111111111111' }); print $result->id; print $result->name;
Handel::Storage::Result is a generic wrapper around objects returned by various Handel::Storage operations. Its main purpose is to abstract storage result objects away from the Cart/Order/Item classes that use them. Each result is assumed to exposed methods for each 'property' or 'column' it has, as well as support the methods described below.
Maps undefined method calls to the underlying result object.
my $storage = Handel::Storage::DBIC::Cart->new; my $result = $storage->create({ shopper => '11111111-1111-1111-1111-111111111111' }); print $result->shopper; #is really this: print $result->storage_result->shopper;
Adds a new item to the current result, returning a storage result object.
my $storage = Handel::Storage::DBIC::Cart->new; my $result = $storage->create({ shopper => '11111111-1111-1111-1111-111111111111' }); my $item = $result->add_item({ sku => 'ABC123' }); print $item->sku;
This method is just a convenience method that forwards to the implementation in the current storage object. See "add_item" in Handel::Storage for more details.
Redirects can requests to the internal storage result object, bypassing AUTOLOAD and returns the code reference if a method is found.
can
Returns the number of items associated with the current result.
my $storage = Handel::Storage::DBIC::Cart->new; my $result = $storage->create({ shopper => '11111111-1111-1111-1111-111111111111' }); $result->add_item({ sku => 'ABC123' }); print $result->count_items; # 1
This method is just a convenience method that forwards to the implementation in the current storage object. See "count_items" in Handel::Storage for more details.
Creates a new instance of Handel::Storage::Result, storing the underlying result for use by AUTOLOAD.
AUTOLOAD
my $schema = $storage->schema_instance; my $row = $schema->resultset($storage->schema_source)->create({ col1 => 'foo', col2 => 'bar' }); my $result = $storage->result_class->create_instance($dbresult, $storage); print $result->foo;
This method is used by the storage object to create storage results from resultset results and assign the generic results with the given storage object.
Deletes the current result and all of it's associated items from the current storage.
my $storage = Handel::Storage::DBIC::Cart->new; my $result = $storage->create({ shopper => '11111111-1111-1111-1111-111111111111' }); $result->add_item({ sku => 'ABC123' }); $result->delete;
This method must be implemented in custom subclasses.
Deletes items matching the filter from the current result.
my $storage = Handel::Storage::DBIC::Cart->new; my $result = $storage->create({ shopper => '11111111-1111-1111-1111-111111111111' }); $result->add_item({ sku => 'ABC123' }); $result->delete_items({ sku => 'ABC%' });
This method is just a convenience method that forwards to the implementation in the current storage object. See "delete_items" in Handel::Storage for more details.
Discards all changes made since the last successful update.
Returns true if the column exists in the current result object.
Same as "search_items".
Returns items matching the filter associated with the current result.
my $storage = Handel::Storage::DBIC::Cart->new; my $result = $storage->search({ id => '11111111-1111-1111-1111-111111111111' }); my $iterator = $result->search_items;
This method is just a convenience method that forwards to the implementation in the current storage object. See "search_items" in Handel::Storage for more details.
Returns the original result created by the underlying storage mechanism. This will be the DBIx::Class::Row result returned from the current schema.
my $storage = Handel::Storage::DBIC::Cart->new; my $result = $storage->create({ shopper => '11111111-1111-1111-1111-111111111111' }); my @columns = $result->storage_result->columns;
It is probably unwise to use the storage result directly anywhere outside of the current result object.
Returns a reference to the storage object used to create the current storage result.
my $storage = Handel::Storage::DBIC::Cart->new; my $result = $storage->create({ shopper => '11111111-1111-1111-1111-111111111111' }); print $result->storage; # Handel::Storage::DBIC::Cart
Starts a transaction on the current storage object.
Commits the current transaction on the current storage object.
Rolls back the current transaction on the current storage object.
Updates the current result with the data specified.
my $storage = Handel::Storage::DBIC::Cart->new; my $result = $storage->create({ shopper => '11111111-1111-1111-1111-111111111111' }); $result->update({ name => 'My Cart' });
Handel::Storage
Christopher H. Laco CPAN ID: CLACO claco@chrislaco.com http://today.icantfocus.com/blog/
To install Handel, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Handel
CPAN shell
perl -MCPAN -e shell install Handel
For more information on module installation, please visit the detailed CPAN module installation guide.