Model::Envoy provides the ability to persist objects via any number of services via plugins. These plugins are referenced in Model::Envoy's role parameters, and dispatched to as needed.
with 'Model::Envoy' => { storage => { 'DBIC' => { schema => sub { ... connect to database here ... } } } };
Any configuration information you need passed into your plugin should be part of the hashref attached to the plugin key in the role parameters.
When Model::Envoy creates an instance of your plugin to track a model object via new(), it will pass in the configuration information and a reference to the model object to track.
Model::Envoy
save
save the data from the model object this instance is tracking to your persistence service.
delete
delete the data from the model object this instance is tracking from your persistence service.
fetch(%params)
This method is expected to take some parameters and return a single Model::Envoy based object in response. Typically this will be an id the plugin uses to look up a record, but it could be multiple parameters depending on the needs of the plugin.
list(%params)
This method is expected to take some search parameters and return an arrayref of zero or more Model::Envoy based objects in response.
configure($self, $conf)
When your models first need to connect to storage, they will call configure on your storage plugin to give it a chance to perform setup that will be needed by all of your instance objects (a database handle, for example).
configure
If you implement this method, you should set the key _configured in the $conf hashref to a true value to tell Model::Envoy that configuration was successful.
_configured
build($class, $model_class, $object, [$no_rel] )
If your plugin knows how to take a particular kind of object (say, a database record class) and turn it into a matching Model::Envoy based object, it should implement this method.
To install Model::Envoy, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Model::Envoy
CPAN shell
perl -MCPAN -e shell install Model::Envoy
For more information on module installation, please visit the detailed CPAN module installation guide.