From: Matt S Trout Date: Sun, 5 May 2013 17:55:18 +0000 (+0000) Subject: switch to a more functional style for the attribute ripping code X-Git-Tag: v1.003000~76 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=74ec40e91abf41f9a5ccc05e6d5e62313342ea43;p=gitmo%2FMoo.git switch to a more functional style for the attribute ripping code --- diff --git a/lib/Moo/HandleMoose.pm b/lib/Moo/HandleMoose.pm index 524b7be..30a97c3 100644 --- a/lib/Moo/HandleMoose.pm +++ b/lib/Moo/HandleMoose.pm @@ -102,22 +102,17 @@ sub inject_real_metaclass_for { $seen_name{$name} = 1; my %spec = %{$attr_specs->{$name}}; my %spec_map = ( - map { $_->name => $_->init_arg } - grep { $_->has_init_arg } - $meta->attribute_metaclass->meta->get_all_attributes + map { $_->name => $_->init_arg||$_->name } + ( + (grep { $_->has_init_arg } + $meta->attribute_metaclass->meta->get_all_attributes), + map { + my $meta = Moose::Util::resolve_metatrait_alias('Attribute', $_) + ->meta; + map $meta->get_attribute($_), $meta->get_attribute_list + } @{$spec{traits}||[]} + ) ); - for my $trait (@{$spec{traits}||[]}) { - my $trait_meta = Moose::Util::resolve_metatrait_alias('Attribute', $trait)->meta; - my @trait_attrs = - map { $trait_meta->get_attribute($_) } - $trait_meta->get_attribute_list; - for my $trait_attr (@trait_attrs) { - my $orig = $trait_attr->original_options; - my $init_arg = (exists $orig->{init_arg} ? $orig->{init_arg} : $trait_attr->name) - or next; - $spec_map{$trait_attr->name} = $init_arg; - } - } $spec{is} = 'ro' if $spec{is} eq 'lazy' or $spec{is} eq 'rwp'; my $coerce = $spec{coerce};