File Coverage

blib/lib/Bread/Board/Service/WithClass.pm
Criterion Covered Total %
statement 12 12 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 16 16 100.0


line stmt bran cond sub pod time code
1             package Bread::Board::Service::WithClass;
2             our $AUTHORITY = 'cpan:STEVAN';
3             # ABSTRACT: role for services returning instances of a given class
4             $Bread::Board::Service::WithClass::VERSION = '0.36';
5 63     63   35717 use Moose::Role;
  63         185  
  63         496  
6 63     63   388342 use Module::Runtime ();
  63         199  
  63         1669  
7              
8 63     63   447 use Bread::Board::Types;
  63         168  
  63         7416  
9              
10             with 'Bread::Board::Service';
11              
12             has 'class' => (
13             is => 'rw',
14             isa => 'Str',
15             predicate => 'has_class',
16             );
17              
18             before 'get' => sub {
19             my $self = shift;
20             Module::Runtime::require_module($self->class)
21             if $self->has_class;
22             };
23              
24 63     63   518 no Moose::Role; 1;
  63         247  
  63         404  
25              
26             __END__
27              
28             =pod
29              
30             =encoding UTF-8
31              
32             =head1 NAME
33              
34             Bread::Board::Service::WithClass - role for services returning instances of a given class
35              
36             =head1 VERSION
37              
38             version 0.36
39              
40             =head1 DESCRIPTION
41              
42             This a sub-role of L<Bread::Board::Service> for services that return
43             instances of a given class.
44              
45             =head1 ATTRIBUTES
46              
47             =head2 C<class>
48              
49             Read/write string attribute, the name of the class that this service
50             will probably instantiate.
51              
52             =head1 METHODS
53              
54             =head2 C<has_class>
55              
56             Predicate for the L</class> attribute, true if it has been set.
57              
58             =head2 C<get>
59              
60             This role adds a C<before> modifier to the C<get> method, ensuring
61             that the module implementing the L</class> is loaded.
62              
63             =head1 AUTHOR
64              
65             Stevan Little <stevan@iinteractive.com>
66              
67             =head1 BUGS
68              
69             Please report any bugs or feature requests on the bugtracker website
70             https://github.com/stevan/BreadBoard/issues
71              
72             When submitting a bug or request, please include a test-file or a
73             patch to an existing test-file that illustrates the bug or desired
74             feature.
75              
76             =head1 COPYRIGHT AND LICENSE
77              
78             This software is copyright (c) 2017, 2016, 2015, 2014, 2013, 2011, 2009 by Infinity Interactive.
79              
80             This is free software; you can redistribute it and/or modify it under
81             the same terms as the Perl 5 programming language system itself.
82              
83             =cut