Envoy/Storage.pm

filter: Statementstmt 100% 9 / 9 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod 100% 2 / 2 totaltotal 100% 14 / 14 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
configure
1.0
build
1.0
CRAP 1.0
« Envoy/Set.pm ↑ Summary
1 package Model::Envoy::Storage;
2  
3 10 our $VERSION = '0.5.3';
4  
5 10 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 10 has 'model' => (
8 is => 'rw',
9 does => 'Model::Envoy',
10 required => 1,
11 weak_ref => 1,
12 );
13  
14 15 ▶sub configure {
Subroutine configure: called CC=1 SCAR=0.0
Pod documented
15 15 my ( $plugin_class, $envoy_class, $conf ) = @_;
16  
17 15 $conf->{_configured} = 1;
18 }
19  
20 1 ▶sub build {
Subroutine build: called CC=1 SCAR=0.0
Pod documented
21  
22 1 return undef;
23 }
24  
25 =head1 Storage Plugins
26  
27 Model::Envoy provides the ability to persist objects via any number of services via plugins. These plugins
28 are referenced in Model::Envoy's role parameters, and dispatched to as needed.
29  
30 =head3 Declaration & Configuration
31  
32 with 'Model::Envoy' => { storage => {
33 'DBIC' => {
34 schema => sub {
35 ... connect to database here ...
36 }
37 }
38 } };
39  
40 Any configuration information you need passed into your plugin should be part of the hashref attached to the plugin
41 key in the role parameters.
42  
43 =head2 Instantiation
44  
45 When C<Model::Envoy> creates an instance of your plugin to track a model object via new(), it will pass in the configuration
46 information and a reference to the model object to track.
47  
48 =head2 Required Methods
49  
50 =head3 C<save>
51  
52 save the data from the model object this instance is tracking to your persistence service.
53  
54 =head3 C<delete>
55  
56 delete the data from the model object this instance is tracking from your persistence service.
57  
58 =head3 C<fetch(%params)>
59  
60 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
61 uses to look up a record, but it could be multiple parameters depending on the needs of the plugin.
62  
63 =head3 C<list(%params)>
64  
65 This method is expected to take some search parameters and return an arrayref of zero or more Model::Envoy based objects in response.
66  
67 =head2 Optional Methods
68  
69 =head3 C<configure($self, $conf)>
70  
71 When your models first need to connect to storage, they will call C<configure>
72 on your storage plugin to give it a chance to perform setup that will be needed
73 by all of your instance objects (a database handle, for example).
74  
75 =over
76  
77 =item $self - the plugin's class
78  
79 =item $conf - the hashref of configuration information specified in Model::Envoy's role parameters
80  
81 =back
82  
83 If you implement this method, you should set the key C<_configured> in the $conf hashref to a true
84 value to tell C<Model::Envoy> that configuration was successful.
85  
86 =head3 C<build($class, $model_class, $object, [$no_rel] )>
87  
88 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,
89 it should implement this method.
90  
91 =over
92  
93 =item $class - the plugin's class
94  
95 =item $model_class - the C<Model::Envoy> based class we're trying to make
96  
97 =item $object - the raw datastructure you'll be trying to turn into the requested $model_class
98  
99 =item $no_rel - an optional boolean to indicate whether to walk the relationship tree of the $object to create more C<Model::Envoy> based objects (to limit recursion).
100  
101 =back
102  
103 =cut
104  
105 10 1;
« Envoy/Set.pm ↑ Summary