File Coverage

blib/lib/Fey/Meta/HasMany/ViaSelect.pm
Criterion Covered Total %
statement 20 20 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod n/a
total 27 27 100.0


line stmt bran cond sub pod time code
1             package Fey::Meta::HasMany::ViaSelect;
2              
3 10     10   52 use strict;
  10         18  
  10         346  
4 10     10   51 use warnings;
  10         18  
  10         375  
5 10     10   51 use namespace::autoclean;
  10         18  
  10         99  
6              
7             our $VERSION = '0.47';
8              
9 10     10   954 use Fey::ORM::Types qw( CodeRef );
  10         18  
  10         99  
10              
11 10     10   48219 use Moose;
  10         21  
  10         95  
12 10     10   60508 use MooseX::StrictConstructor;
  10         22  
  10         96  
13              
14             with 'Fey::Meta::Role::Relationship::HasMany';
15              
16             has 'select' => (
17             is => 'ro',
18             does => 'Fey::Role::SQL::ReturnsData',
19             required => 1,
20             );
21              
22             has 'bind_params' => (
23             is => 'ro',
24             isa => CodeRef,
25             );
26              
27             ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines)
28             sub _make_iterator_maker {
29 2     2   4 my $self = shift;
30              
31 2         576 return $self->_make_subref_for_sql(
32             $self->select(),
33             $self->bind_params(),
34             );
35             }
36             ## use critic
37              
38             __PACKAGE__->meta()->make_immutable();
39              
40             1;
41              
42             # ABSTRACT: A parent for has-one metaclasses based on a query object
43              
44             __END__
45              
46             =pod
47              
48             =head1 NAME
49              
50             Fey::Meta::HasMany::ViaSelect - A parent for has-one metaclasses based on a query object
51              
52             =head1 VERSION
53              
54             version 0.47
55              
56             =head1 DESCRIPTION
57              
58             This class implements a has-one relationship for a class, based on a
59             provided (or deduced) query object.
60              
61             =head1 CONSTRUCTOR OPTIONS
62              
63             This class accepts the following constructor options:
64              
65             =over 4
66              
67             =item * select
68              
69             An object which does the L<Fey::Role::SQL::ReturnsData> role. This query
70             defines the relationship between the tables.
71              
72             =item * bind_params
73              
74             An optional subroutine reference which will be called when the SQL is
75             executed. It is called as a method on the object of this object's
76             associated class.
77              
78             =item * allows_undef
79              
80             This defaults to true.
81              
82             =back
83              
84             =head1 METHODS
85              
86             Besides the methods provided by L<Fey::Meta::Role::Relationship::HasMany>,
87             this class also provides the following methods:
88              
89             =head2 $ho->select()
90              
91             Corresponds to the value passed to the constructor.
92              
93             =head2 $ho->bind_params()
94              
95             Corresponds to the value passed to the constructor.
96              
97             =head1 AUTHOR
98              
99             Dave Rolsky <autarch@urth.org>
100              
101             =head1 COPYRIGHT AND LICENSE
102              
103             This software is copyright (c) 2011 - 2015 by Dave Rolsky.
104              
105             This is free software; you can redistribute it and/or modify it under
106             the same terms as the Perl 5 programming language system itself.
107              
108             =cut