From: Jesse Luehrs Date: Thu, 11 Nov 2010 04:56:44 +0000 (-0600) Subject: use _eval_environment here X-Git-Tag: 1.9900~34 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d64f9b2a346c44f1b5663167b111844932342f44;p=gitmo%2FMoose.git use _eval_environment here --- diff --git a/lib/Moose/Meta/Method/Constructor.pm b/lib/Moose/Meta/Method/Constructor.pm index 6e9ef96..42b58fe 100644 --- a/lib/Moose/Meta/Method/Constructor.pm +++ b/lib/Moose/Meta/Method/Constructor.pm @@ -83,29 +83,8 @@ sub _initialize_body { # because the inlined code is using the index of the attributes # to determine where to find the type constraint - my $attrs = $self->_attributes; - - my @type_constraints = map { - $_->can('type_constraint') ? $_->type_constraint : undef - } @$attrs; - - my @type_constraint_bodies = map { - defined $_ ? $_->_compiled_type_constraint : undef; - } @type_constraints; - - my $defaults = [map { $_->default } @$attrs]; - my $code = try { - $self->_compile_code( - source => \@source, - environment => { - '$meta' => \$self, - '$attrs' => \$attrs, - '$defaults' => \$defaults, - '@type_constraints' => \@type_constraints, - '@type_constraint_bodies' => \@type_constraint_bodies, - }, - ); + $self->_compile_code(\@source); } catch { my $source = join("\n", @source); @@ -119,6 +98,30 @@ sub _initialize_body { $self->{'body'} = $code; } +sub _eval_environment { + my $self = shift; + + my $attrs = $self->_attributes; + + my $defaults = [map { $_->default } @$attrs]; + + my @type_constraints = map { + $_->can('type_constraint') ? $_->type_constraint : undef + } @$attrs; + + my @type_constraint_bodies = map { + defined $_ ? $_->_compiled_type_constraint : undef; + } @type_constraints; + + return { + '$meta' => \$self, + '$attrs' => \$attrs, + '$defaults' => \$defaults, + '@type_constraints' => \@type_constraints, + '@type_constraint_bodies' => \@type_constraint_bodies, + }; +} + sub _generate_fallback_constructor { my $self = shift; my ($class_var) = @_;