aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Reaction/UI/ViewPort/Object.pm
diff options
context:
space:
mode:
authoredenc <edenc@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7>2009-01-28 23:06:24 +0000
committeredenc <edenc@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7>2009-01-28 23:06:24 +0000
commitf5e2ab69e2045b9ffe04b7436c7e2cf51bc4c4e9 (patch)
tree973a06f93e74d08e7338204f76b401ffc124e54b /lib/Reaction/UI/ViewPort/Object.pm
parent46ce622d342de1ad3bef7354e4653ddc91fabaf1 (diff)
downloadreaction-f5e2ab69e2045b9ffe04b7436c7e2cf51bc4c4e9.tar.gz
reaction-f5e2ab69e2045b9ffe04b7436c7e2cf51bc4c4e9.zip
added included_fields patch from abs
Diffstat (limited to 'lib/Reaction/UI/ViewPort/Object.pm')
-rw-r--r--lib/Reaction/UI/ViewPort/Object.pm14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/Reaction/UI/ViewPort/Object.pm b/lib/Reaction/UI/ViewPort/Object.pm
index ed68f20..28eea32 100644
--- a/lib/Reaction/UI/ViewPort/Object.pm
+++ b/lib/Reaction/UI/ViewPort/Object.pm
@@ -29,6 +29,7 @@ has field_order => (is => 'ro', isa => 'ArrayRef');
has builder_cache => (is => 'ro', isa => 'HashRef', lazy_build => 1);
has excluded_fields => (is => 'ro', isa => 'ArrayRef', lazy_build => 1);
+has included_fields => (is => 'ro', isa => 'ArrayRef', lazy_build => 1);
has computed_field_order => (is => 'ro', isa => 'ArrayRef', lazy_build => 1);
has containers => ( is => 'ro', isa => 'ArrayRef', lazy_build => 1);
@@ -43,6 +44,7 @@ sub BUILD {
sub _build_builder_cache { {} }
sub _build_excluded_fields { [] }
+sub _build_included_fields { [] }
sub _build_containers {
my $self = shift;
@@ -105,8 +107,10 @@ sub _build_fields {
sub _build_computed_field_order {
my ($self) = @_;
my %excluded = map { $_ => undef } @{ $self->excluded_fields };
+ my %included = map { $_ => undef } @{ $self->included_fields };
#treat _$field_name as private and exclude fields with no reader
- my @names = grep { $_ !~ /^_/ && !exists($excluded{$_})} map { $_->name }
+ my @names = grep { $_ !~ /^_/ && (!%included || exists( $included{$_}) )
+ && !exists($excluded{$_}) } map { $_->name }
grep { defined $_->get_read_method } $self->model->parameter_attributes;
return $self->sort_by_spec($self->field_order || [], \@names);
}
@@ -265,6 +269,14 @@ Reaction::UI::ViewPort::Object
=head2 excluded_fields
+List of field names to exclude.
+
+=head2 included_fields
+
+List of field names to include. If both C<included_fields> and
+C<excluded_fields> are specified the result is those fields which
+are in C<included_fields> and not in C<excluded_fields>.
+
=head2 computed_field_order
=head1 INTERNAL METHODS