use Data::Dump qw( pp );
use MooseX::Types::Util qw( has_available_type_export );
use Moose::Util qw( add_method_modifier ensure_all_roles );
+ use Data::Pond qw(pond_write_datum);
use Class::Inspector;
use Class::MOP;
next if $attr eq 'Chained' and $value eq UNDER_VAR;
push @attributes,
- map { sprintf '%s%s', $attr, defined($_) ? sprintf('(%s)', $_) : '' }
- (ref($value) eq 'ARRAY')
- ? @$value
- : $value;
+ map {
+ my $value = ref $_ ? pond_write_datum($_) : $_;
+ sprintf '%s%s', $attr, defined($value) ? sprintf('(%s)', $value) : ''
+ } (
+ ref($value) eq 'ARRAY'
+ ) ? @$value : $value;
}
return \@attributes;
# merge runtime and compiletime attrs
my %full_attrs = (%attributes, %$attrs);
my $compiled_attrs = $compile_attrs->(\%full_attrs);
-
my $real_method = $method->reify(
actual_body => $body,
attributes => $compiled_attrs,
# NYI
if ($modifier) {
-
add_method_modifier $class, $modifier, [$name, $real_method];
}
else {
$real_meta->$prepare_meta;
}
else {
-
$class->meta->$prepare_meta;
}
}
my ($first, @rest) = eval $params;
my %params = ref $first eq 'HASH' ? %$first : ($first, @rest); # both (%opts) and {%opts}
for my $key (keys %params) {
- my $parameters = ref $params{$key} eq 'ARRAY' ? @{$params{$key}} : $params{$key};
- push @{$attrs->{$key}}, $parameters;
+ my $value = ref $params{$key} eq 'ARRAY' ? $params{$key} : [$params{$key}];
+ push @{ $attrs->{$key} ||=[] }, @$value;
+ ##push @{ $attrs->{$key} ||=[] }, $params;
+
}
- $attrs->{_role_attributes}->{$role} = \%params;
}
if (defined(my $alias = $self->_check_for_available_import($ctx, $role))) {
}
push @{ $attrs->{CatalystX_Declarative_ActionRoles} ||= [] }, @roles;
-
return;
}
$attrs->{Signature} = $proto;
$attrs->{Action} = [];
- push @{ $attrs->{CatalystX_Declarative_ActionRoles} ||= [] }, CatchValidationError;
+ push @{ $attrs->{CatalystX_Declarative_DefaultActionRoles} ||= [] }, CatchValidationError;
# default chained base to the global under var, to be resolved at runtime
$attrs->{Chained} ||= UNDER_VAR;
sub User :Action :Does(Permissions) :roles(admin) :roles(member)
-However, I realize this method could lead to namespace collisions. So in
-addition to putting paramters into $action->attributes, we also populate a
-special key "_role_attributes", which will preserve parameters by role:
-
- $action->attributes->{_role_attributes}->{$role} = \%params;
-
-So the following:
-
- action User with Permissions(roles=>[qw/admin member/]) {}
-
-Creates:
-
- $action->attributes->{_role_attributes}->{Permissions}
- = {roles=>[qw/admin member/]};
-
-For now you should only use this for your private code.
+However, I realize this method could lead to namespace collisions within the
+C<$action->attributes> attribute. For now this is an avoidable issue. In the
+future we may add a C<$action->trait_attributes> or similar attribute to the
+L<Catalyst::Action> class in order to resolve this issue.
=head2 Action Classes