my $attributes = $self->parse_reflect_rules($attr_rules, $attr_haystack);
#create the class
+ warn $class;
my $meta = eval { Class::MOP::load_class($class) } ?
$class->meta : $base->meta->create($class, superclasses => [$base]);
my $make_immutable = $meta->is_immutable || $self->make_classes_immutable;
);
if ($attr_opts{required}) {
- $attr_opts{lazy} = 1;
- $attr_opts{default} = $from_attr->has_default ?
- $from_attr->default : sub{};
+ if($from_attr->has_default) {
+ $attr_opts{lazy} = 1;
+ $attr_opts{default} = $from_attr->default;
+ } else {
+ $attr_opts{lazy_fail} = 1;
+ }
}
#test for relationships
class Field is 'Reaction::UI::ViewPort', which {
- has value => (is => 'rw', lazy_build => 1);
+ has value => (is => 'rw', lazy_fail => 1);
has name => (is => 'rw', isa => 'Str', lazy_build => 1);
has label => (is => 'rw', isa => 'Str', lazy_build => 1);
has value_string => (is => 'rw', isa => 'Str', lazy_build => 1);
implements adopt_value => as {};
implements _build_name => as { shift->attribute->name };
- implements _build_value_string => as { shift->value };
+
+ implements _build_value_string => as {
+ my($self) = @_;
+ return $self->has_value? $self->value : '';
+ };
implements _build_label => as {
join(' ', map { ucfirst } split('_', shift->name));
};
- #unlazify and move it to build. to deal with array use typeconstraints and coercions
- implements _build_value => as {
- my ($self) = @_;
+ implements BUILD => as {
+ my($self) = @_;
my $reader = $self->attribute->get_read_method;
my $predicate = $self->attribute->predicate;
|| ($self->attribute->is_lazy
&& !$self->attribute->is_lazy_fail)
) {
- return $self->model->$reader;
+ $self->value($self->model->$reader);
}
- return $self->_empty_value;
- };
- implements _empty_value => as { '' };
+ };
};
class Collection is Array, which {
- #XXX
- override _build_value => sub {
- my $collection = super();
- return blessed($collection) ? [$collection->members] : $collection;
- };
-
};
1;
class Boolean is 'Reaction::UI::ViewPort::Field::Boolean', which{
does 'Reaction::UI::ViewPort::Field::Role::Mutable';
+
+ implements BUILD => as {
+ my($self) = @_;
+ $self->value(0) unless $self->has_value;
+ };
+
};
1;
$orig->($self, $checked);
};
- #XXX go away!
- override _build_value => sub {
- return super() || [];
- };
-
implements _build_value_string => as {
my $self = shift;
join ", ", (map {$self->obj_to_name($_->{value}) } @{ $self->current_value_choices })
implements _build_value_string => as {
my $self = shift;
+ return unless $self->has_value;
my $value = $self->value;
return $self->obj_to_name($value->{value}) if Scalar::Util::blessed($value);
$value;
implements is_current_value => as {
my ($self, $check_value) = @_;
+ return unless $self->has_value;
my $our_value = $self->value;
return unless ref($our_value);
$check_value = $self->obj_to_str($check_value) if ref($check_value);
if ($_{viewport}->can('value_string')) {
arg 'field_value' => $_{viewport}->value_string;
} else {
- arg 'field_value' => $_{viewport}->value;
+ arg 'field_value' => ''; #$_{viewport}->value;
}
};
class Boolean is 'Reaction::UI::Widget::Field::Mutable', which {
+ after fragment widget {
+ arg 'field_type' => 'checkbox';
+ };
+
implements fragment is_checked {
if ($_{viewport}->value) {
render 'is_checked_yes';