Move the eval_environment wrapper to the Class trait from Constructor
[gitmo/MooseX-StrictConstructor.git] / lib / MooseX / StrictConstructor / Trait / Method / Constructor.pm
index ae5d3fb..219e044 100644 (file)
@@ -6,19 +6,17 @@ use namespace::autoclean;
 
 use B ();
 
-around '_generate_BUILDALL' => sub {
+around _generate_BUILDALL => sub {
     my $orig = shift;
     my $self = shift;
 
     my $source = $self->$orig();
     $source .= ";\n" if $source;
 
-    my @attrs = (
-        '__INSTANCE__ => 1,',
-        map { B::perlstring($_) . ' => 1,' }
-        grep {defined}
-        map  { $_->init_arg() } @{ $self->_attributes() }
-    );
+    my @attrs = '__INSTANCE__ => 1,';
+    push @attrs, map { B::perlstring($_) . ' => 1,' }
+        grep { defined }
+        map  { $_->init_arg() } @{ $self->_attributes() };
 
     $source .= <<"EOF";
 my \%attrs = (@attrs);
@@ -33,24 +31,6 @@ EOF
     return $source;
 } if $Moose::VERSION < 1.9900;
 
-around _eval_environment => sub {
-    my $orig = shift;
-    my $self = shift;
-
-    my $env = $self->$orig();
-
-    my %attrs = map { $_ => 1 }
-        grep { defined }
-        map  { $_->init_arg() }
-        $self->associated_metaclass()->get_all_attributes();
-
-    $attrs{__INSTANCE__} = 1;
-
-    $env->{'%allowed_attrs'} = \%attrs;
-
-    return $env;
-} if $Moose::VERSION >= 1.9900;
-
 1;
 
 # ABSTRACT: A role to make immutable constructors strict