X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FReaction%2FUI%2FViewPort%2FObject.pm;h=73facb9d06f76590c16163cdda37f9adcea4f3dd;hb=56c5a4a1e847761faf792d9f1b3aebc17a85744d;hp=da45c23431618c0df785b89f510cd1297dde93e2;hpb=cc44a3371f6bb93dfcc28961004b00064942e27b;p=catagits%2FReaction.git diff --git a/lib/Reaction/UI/ViewPort/Object.pm b/lib/Reaction/UI/ViewPort/Object.pm index da45c23..73facb9 100644 --- a/lib/Reaction/UI/ViewPort/Object.pm +++ b/lib/Reaction/UI/ViewPort/Object.pm @@ -11,6 +11,7 @@ use aliased 'Reaction::UI::ViewPort::Field::DateTime'; use aliased 'Reaction::UI::ViewPort::Field::RelatedObject'; use aliased 'Reaction::UI::ViewPort::Field::Array'; use aliased 'Reaction::UI::ViewPort::Field::Collection'; +use aliased 'Reaction::UI::ViewPort::Field::File'; use aliased 'Reaction::InterfaceModel::Object' => 'IM_Object'; @@ -21,7 +22,7 @@ class Object is 'Reaction::UI::ViewPort', which { has model => (is => 'ro', isa => IM_Object, required => 1); has fields => (is => 'ro', isa => 'ArrayRef', lazy_build => 1); - has field_args => (is => 'ro'); + has field_args => (is => 'rw'); has field_order => (is => 'ro', isa => 'ArrayRef'); has builder_cache => (is => 'ro', isa => 'HashRef', lazy_build => 1); @@ -74,11 +75,13 @@ class Object is 'Reaction::UI::ViewPort', which { my $constraint = $attr->type_constraint; my $base_name = $constraint->name; my $tried_isa = 0; + my @tried; CONSTRAINT: while (defined($constraint)) { my $name = $constraint->name; $name = $attr->_isa_metadata if($name eq '__ANON__'); if (eval { $name->can('meta') } && !$tried_isa++) { foreach my $class ($name->meta->class_precedence_list) { + push(@tried, $class); my $mangled_name = $class; $mangled_name =~ s/:+/_/g; my $builder = "_build_fields_for_type_${mangled_name}"; @@ -86,6 +89,7 @@ class Object is 'Reaction::UI::ViewPort', which { } } if (defined($name)) { + push(@tried, $name); unless (defined($base_name)) { $base_name = "(anon subtype of ${name})"; } @@ -97,7 +101,9 @@ class Object is 'Reaction::UI::ViewPort', which { $constraint = $constraint->parent; } if (!defined($constraint)) { - confess "Can't build field ${attr_name} of type ${base_name} without $builder method or _build_fields_for_type_ method for type or any supertype"; + confess "Can't build field ${attr_name} of type ${base_name} without " + ."$builder method or _build_fields_for_type_ method " + ."for type or any supertype (tried ".join(', ', @tried).")"; } } else { confess "Can't build field ${attr} without $builder method or type constraint"; @@ -138,7 +144,7 @@ class Object is 'Reaction::UI::ViewPort', which { }; #XXX - implements _build_fields_for_type_Password => as { return }; + implements _build_fields_for_type_Reaction_Types_Core_Password => as { return }; implements _build_fields_for_type_Str => as { my ($self, $attr, $args) = @_; @@ -146,12 +152,12 @@ class Object is 'Reaction::UI::ViewPort', which { $self->_build_simple_field(attribute => $attr, class => String, %$args); }; - implements _build_fields_for_type_SimpleStr => as { + implements _build_fields_for_type_Reaction_Types_Core_SimpleStr => as { my ($self, $attr, $args) = @_; $self->_build_simple_field(attribute => $attr, class => String, %$args); }; - implements _build_fields_for_type_DateTime => as { + implements _build_fields_for_type_Reaction_Types_DateTime_DateTimeObject => as { my ($self, $attr, $args) = @_; $self->_build_simple_field(attribute => $attr, class => DateTime, %$args); }; @@ -167,6 +173,11 @@ class Object is 'Reaction::UI::ViewPort', which { $self->_build_simple_field(attribute => $attr, class => Array, %$args); }; + implements _build_fields_for_type_File => as { + my ($self, $attr, $args) = @_; + $self->_build_simple_field(attribute => $attr, class => File, %$args); + }; + implements _build_fields_for_type_Reaction_InterfaceModel_Object => as { my ($self, $attr, $args) = @_; #XXX @@ -181,3 +192,71 @@ class Object is 'Reaction::UI::ViewPort', which { }; 1; + +__END__; + +=head1 NAME + +Reaction::UI::ViewPort::Object + +=head1 DESCRIPTION + +=head1 ATTRIBUTES + +=head2 model + +=head2 fields + +=head2 field_args + +=head2 field_order + +=head2 builder_cache + +=head2 excluded_fields + +=head2 computed_field_order + +=head1 INTERNAL METHODS + +These methods, although stable, are subject to change without notice. These are meant +to be used only by developers. End users should refrain from using these methods to +avoid potential breakages. + +=head2 BUILD + +=head2 get_builder_for + +=head2 _build_simple_field + +=head2 _build_fields_for_type_Num + +=head2 _build_fields_for_type_Int + +=head2 _build_fields_for_type_Bool + +=head2 _build_fields_for_type_Password + +=head2 _build_fields_for_type_Str + +=head2 _build_fields_for_type_SimpleStr + +=head2 _build_fields_for_type_DateTime + +=head2 _build_fields_for_type_Enum + +=head2 _build_fields_for_type_ArrayRef + +=head2 _build_fields_for_type_Reaction_InterfaceModel_Object + +=head2 _build_fields_for_type_Reaction_InterfaceModel_Collection + +=head1 AUTHORS + +See L for authors. + +=head1 LICENSE + +See L for the license. + +=cut