new component to make m2ms introspectables so we can hint the reflector
[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
6role Where, which {
7
8 #requires qw/_source_resultset _im_class/;
7adfd53f 9 implements where => as {
10 my $self = shift;
11 my $rs = $self->_source_resultset->search_rs(@_);
12 return (blessed $self)->new(
13 _source_resultset => $rs,
c8fbb8ad 14 member_type => $self->member_type
7adfd53f 15 );
16 };
17
18 implements add_where => as {
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;
24 };
25
f670cfd0 26 #XXX may need a rename, but i needed this for ListView
27 implements find => as {
28 my $self = shift;
29 $self->_source_resultset
c8fbb8ad 30 ->search({},{result_class => $self->member_type})
f670cfd0 31 ->find(@_);
32 };
7adfd53f 33};
34
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