NAME

EntityModel::Support::Perl::Base - base class for entity instances

VERSION

version 0.001

SYNOPSIS

say $_->name foreach Entity::Thing->find({name=>'test'});

DESCRIPTION

All entities are derived from this base class by default.

new

Instantiate from an ID or a pre-fabricated object (hashref).

_spec_from_hashref

Private method to generate hashref containing spec information suitable for bless to requested class, given a hashref which represents the keys/values for the object.

This will flatten any Entity objects down to the required ID key+values.

create

Create a new object.

Takes a hashref, and sets the flag so that ->commit does the insert.

find

Search for entities that match the given spec.

Generates a query from the spec, and uses that to locate any matching objects, instantiating them as required.

  • $spec - hashref (or plain hash) of search options

Example:

Entity::Thing->find(
	name => 'test'
);

TODO Not yet supported

_update

Write current values back to storage.

_select

Populate this instance with values from the database.

_pending_insert

Returns true if this instance is due to be committed to the database.

_pending_update

Returns true if this instance is due to be committed to the database.

_insert

Insert this instance into the db.

commit

Commit any pending changes to the database.

revert

Revert any pending changes to the database.

id

Primary key (id) for this instance.

fromID

Instantiate from an ID.

remove

Remove this instance from the database.

_view

Returns the view corresponding to this object.

AUTHOR

Tom Molesworth <cpan@entitymodel.com>

LICENSE

Copyright Tom Molesworth 2008-2011. Licensed under the same terms as Perl itself.