do not include .git directory
[catagits/Reaction.git] / lib / Reaction / InterfaceModel / Collection / DBIC / Role / Where.pm
CommitLineData
7adfd53f 1package Reaction::InterfaceModel::Collection::DBIC::Role::Where;
2
3use Reaction::Role;
4use Scalar::Util qw/blessed/;
5
81393881 6use namespace::clean -except => [ qw(meta) ];
7
8
9#requires qw/_source_resultset _im_class/;
10sub 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};
18sub 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
27sub find {
28 my $self = shift;
29 $self->_source_resultset
30 ->search({},{result_class => $self->member_type})
31 ->find(@_);
32};
33
34
7adfd53f 351;
36
37=head1 NAME
38
39Reaction::InterfaceModel::Collection::DBIC::Role::Where
40
41=head1 DESCRIPTION
42
43Provides methods to allow a ResultSet collection to be restricted
44
45=head1 METHODS
46
47=head2 where
48
49Will return a clone with a restricted C<_source_resultset>.
50
51=head2 add_where
52
53Will return itself after restricting C<_source_resultset>. This also clears the
54C<_collection_store>
55
56=head1 AUTHORS
57
58See L<Reaction::Class> for authors.
59
60=head1 LICENSE
61
62See L<Reaction::Class> for the license.
63
64=cut