Reaction::InterfaceModel::Collection::DBIC::Role::Where - Reaction::InterfaceModel::Collection::DBIC::Role::Where documentation


Reaction documentation Contained in the Reaction distribution.

Index


Code Index:

NAME

Top

Reaction::InterfaceModel::Collection::DBIC::Role::Where

DESCRIPTION

Top

Provides methods to allow a ResultSet collection to be restricted

METHODS

Top

where

Will return a clone with a restricted _source_resultset.

add_where

Will return itself after restricting _source_resultset. This also clears the _collection_store

AUTHORS

Top

See Reaction::Class for authors.

LICENSE

Top

See Reaction::Class for the license.


Reaction documentation Contained in the Reaction distribution.

package Reaction::InterfaceModel::Collection::DBIC::Role::Where;

use Reaction::Role;
use Scalar::Util qw/blessed/;

use namespace::clean -except => [ qw(meta) ];


#requires qw/_source_resultset _im_class/;
sub where {
  my $self = shift;
  my $rs = $self->_source_resultset->search_rs(@_);
  return (blessed $self)->new(
                              _source_resultset => $rs,
                              member_type => $self->member_type
                             );
};
sub add_where {
  my $self = shift;
  my $rs = $self->_source_resultset->search_rs(@_);
  $self->_source_resultset($rs);
  $self->_clear_collection_store if $self->_has_collection_store;
  return $self;
};

#XXX may need a rename, but i needed this for ListView
sub find {
  my $self = shift;
  $self->_source_resultset
    ->search({},{result_class => $self->member_type})
      ->find(@_);
};


1;