diff options
author | phaylon <phaylon@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7> | 2009-03-27 02:40:02 +0000 |
---|---|---|
committer | phaylon <phaylon@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7> | 2009-03-27 02:40:02 +0000 |
commit | e653a48785a1942da650254c8fba30706ca18333 (patch) | |
tree | e0478436bd4a61b1d34af9cf1e770e7e02dba99f /lib/Reaction/UI/ViewPort/Collection | |
parent | 0feb9d76b60db643a717dded5c19efb8f049f642 (diff) | |
download | reaction-e653a48785a1942da650254c8fba30706ca18333.tar.gz reaction-e653a48785a1942da650254c8fba30706ca18333.zip |
search spec components factored out of T365
Diffstat (limited to 'lib/Reaction/UI/ViewPort/Collection')
-rw-r--r-- | lib/Reaction/UI/ViewPort/Collection/Role/UseSearchSpec.pm | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/Reaction/UI/ViewPort/Collection/Role/UseSearchSpec.pm b/lib/Reaction/UI/ViewPort/Collection/Role/UseSearchSpec.pm new file mode 100644 index 0000000..5949056 --- /dev/null +++ b/lib/Reaction/UI/ViewPort/Collection/Role/UseSearchSpec.pm @@ -0,0 +1,35 @@ +package Reaction::UI::ViewPort::Collection::Role::UseSearchSpec; + +use Reaction::Role; +use aliased 'Reaction::InterfaceModel::Search::Spec' => 'SearchSpecRole'; +use Scalar::Util qw(weaken); +use Method::Signatures::Simple; +use signatures; +use namespace::clean -except => 'meta'; + +has 'search_spec' => (isa => SearchSpecRole, is => 'ro', required => 1); + +has '_search_spec_cb' => (is => 'ro', lazy_build => 1); + +method _build__search_spec_cb () { + my $object = $self; + weaken($object); + my $cb = sub { $object->clear_current_collection }; +} + +method _filter_collection_using_search_spec($coll) { + $self->search_spec->filter_collection($coll); +} + +method _register_self_with_search_spec () { + my $cb = $self->_search_spec_cb; + $self->search_spec->register_dependent($self, $cb); +} + +around _build_current_collection => sub ($orig, $self, @rest) { + my $coll = $self->$orig(@rest); + return $self->_filter_collection_using_search_spec($coll); +}; + +1; + |