added search spec sample to demo app
[catagits/Reaction.git] / lib / ComponentUI / TestModel / Foo / SearchSpec.pm
1 package ComponentUI::TestModel::Foo::SearchSpec;
2 use Reaction::Class;
3 use namespace::autoclean;
4
5 use MooseX::Types::Common::String qw/NonEmptySimpleStr/;
6
7 with 'Reaction::InterfaceModel::Search::Spec';
8
9 has 'first_name' => (isa => NonEmptySimpleStr, is => 'rw', required => 0);
10 has 'last_name' => (isa => NonEmptySimpleStr, is => 'rw', required => 0);
11
12 sub _build__search_spec {
13   my($self) = @_;
14   my %search;
15   $search{first_name} = $self->first_name if $self->has_first_name;
16   $search{last_name} = $self->last_name if $self->has_last_name;
17   return [\%search];
18 }
19
20 # no special packing/unpacking required for Foo
21 sub _to_string_pack_value { $_[1] }
22 sub _from_string_unpack_value { $_[1] }
23
24 1;