File Coverage

blib/lib/Bolts/Meta/Initializer.pm
Criterion Covered Total %
statement 10 10 100.0
branch 2 2 100.0
condition 2 3 66.6
subroutine 3 3 100.0
pod 2 2 100.0
total 19 20 95.0


line stmt bran cond sub pod time code
1             package Bolts::Meta::Initializer;
2             $Bolts::Meta::Initializer::VERSION = '0.142930';
3             # ABSTRACT: Store a path and parameters for acquisition
4              
5 8     8   34 use Moose;
  8         11  
  8         51  
6              
7              
8             has path => (
9             is => 'ro',
10             isa => 'ArrayRef[Str]',
11             required => 1,
12             traits => [ 'Array' ],
13             handles => { list_path => 'elements' },
14             );
15              
16              
17             has parameters => (
18             is => 'ro',
19             isa => 'HashRef',
20             required => 1,
21             );
22              
23              
24             sub BUILDARGS {
25 2     2 1 5 my ($self, @path) = @_;
26              
27 2         4 my $parameters = {};
28 2 100 66     10 if (@path > 1 and ref $path[-1]) {
29 1         3 $parameters = pop @path;
30             }
31              
32             return {
33 2         73 path => \@path,
34             parameters => $parameters,
35             };
36             }
37              
38              
39             sub get {
40 2     2 1 4 my $self = shift;
41 2         70 return ($self->list_path, $self->parameters);
42             }
43              
44             __PACKAGE__->meta->make_immutable;
45              
46             __END__
47              
48             =pod
49              
50             =encoding UTF-8
51              
52             =head1 NAME
53              
54             Bolts::Meta::Initializer - Store a path and parameters for acquisition
55              
56             =head1 VERSION
57              
58             version 0.142930
59              
60             =head1 DESCRIPTION
61              
62             Describes an initializer, which is just a path and set of parameters used to make a call to L<Bolts::Role::Locator/acquire> within a L<Bolts::Role::Initializer> for any attributed tagged with the C<Bolts::Initializer> trait.
63              
64             =head1 ATTRIBUTES
65              
66             =head2 path
67              
68             This is the path that is passed into the constructor.
69              
70             =head2 parameters
71              
72             This is a reference to the hash of parameters passsed into the constructor (or an empty hash if none was passed).
73              
74             =head1 METHODS
75              
76             =head2 new
77              
78             my $init = Bolts::Meta::Initailizer->new(@path, \%parameters);
79              
80             The C<BUILDARGS> for this object has been modified so that the constructor takes arguments in the same form as L<Bolts::Role::Locator/acquire>.
81              
82             =head2 get
83              
84             my (@path, \%parameters) = $init->get;
85              
86             Returns the contents of this object in a form that can be passed directly on to L<Bolts::Role::Locator/acquire>.
87              
88             =head1 AUTHOR
89              
90             Andrew Sterling Hanenkamp <hanenkamp@cpan.org>
91              
92             =head1 COPYRIGHT AND LICENSE
93              
94             This software is copyright (c) 2014 by Qubling Software LLC.
95              
96             This is free software; you can redistribute it and/or modify it under
97             the same terms as the Perl 5 programming language system itself.
98              
99             =cut