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