Commit | Line | Data |
7adfd53f |
1 | package Reaction::InterfaceModel::Collection::DBIC::Role::Where; |
2 | |
3 | use Reaction::Role; |
4 | use Scalar::Util qw/blessed/; |
5 | |
81393881 |
6 | use namespace::clean -except => [ qw(meta) ]; |
7 | |
8 | |
9 | #requires qw/_source_resultset _im_class/; |
10 | sub where { |
11 | my $self = shift; |
12 | my $rs = $self->_source_resultset->search_rs(@_); |
13 | return (blessed $self)->new( |
14 | _source_resultset => $rs, |
15 | member_type => $self->member_type |
16 | ); |
17 | }; |
18 | sub add_where { |
19 | my $self = shift; |
20 | my $rs = $self->_source_resultset->search_rs(@_); |
21 | $self->_source_resultset($rs); |
22 | $self->_clear_collection_store if $self->_has_collection_store; |
23 | return $self; |
7adfd53f |
24 | }; |
25 | |
81393881 |
26 | #XXX may need a rename, but i needed this for ListView |
27 | sub find { |
28 | my $self = shift; |
29 | $self->_source_resultset |
30 | ->search({},{result_class => $self->member_type}) |
31 | ->find(@_); |
32 | }; |
33 | |
34 | |
7adfd53f |
35 | 1; |
36 | |
37 | =head1 NAME |
38 | |
39 | Reaction::InterfaceModel::Collection::DBIC::Role::Where |
40 | |
41 | =head1 DESCRIPTION |
42 | |
43 | Provides methods to allow a ResultSet collection to be restricted |
44 | |
45 | =head1 METHODS |
46 | |
47 | =head2 where |
48 | |
49 | Will return a clone with a restricted C<_source_resultset>. |
50 | |
51 | =head2 add_where |
52 | |
53 | Will return itself after restricting C<_source_resultset>. This also clears the |
54 | C<_collection_store> |
55 | |
56 | =head1 AUTHORS |
57 | |
58 | See L<Reaction::Class> for authors. |
59 | |
60 | =head1 LICENSE |
61 | |
62 | See L<Reaction::Class> for the license. |
63 | |
64 | =cut |