# NOTE:
# set up the environment
+ my $environment = q{
my $attr = $self->associated_attribute;
my $attr_name = $attr->name;
- my $meta = $self,
+ my $meta = $self;
my $type_constraint_obj = $attr->type_constraint;
my $type_constraint_name = $type_constraint_obj && $type_constraint_obj->name;
my $type_constraint = $type_constraint_obj
? $type_constraint_obj->_compiled_type_constraint
: undef;
+};
#warn "code for $attr_name =>\n" . $code . "\n";
- my $sub = eval $code;
- $self->throw_error("Could not create writer for '$attr_name' because $@ \n code: $code", error => $@, data => $code ) if $@;
+ my $sub = $self->_eval_closure($environment, $code);
+ $self->throw_error("Could not create writer for '${\$self->associated_attribute->name}' because $@ \n code: $code", error => $@, data => $code ) if $@;
return $sub;
}
warn $source if $self->options->{debug};
my $code;
- {
+ my $environment = q{
my $meta = $self; # FIXME for _inline_throw_error...
# NOTE:
my @type_constraint_bodies = map {
defined $_ ? $_->_compiled_type_constraint : undef;
} @type_constraints;
-
- $code = eval $source;
- $self->throw_error("Could not eval the constructor :\n\n$source\n\nbecause :\n\n$@", error => $@, data => $source ) if $@;
- }
+ };
+ $code = $self->_eval_closure($environment, $source);
+ $self->throw_error("Could not eval the constructor :\n\n$source\n\nbecause :\n\n$@", error => $@, data => $source ) if $@;
$self->{'body'} = $code;
}
$source .= ";\n" . '}';
warn $source if $self->options->{debug};
- my $code;
- {
- $code = eval $source;
- $self->throw_error("Could not eval the destructor :\n\n$source\n\nbecause :\n\n$@", error => $@, data => $source) if $@;
- }
+ my $code = $self->_eval_closure(q{}, $source);
+ $self->throw_error("Could not eval the destructor :\n\n$source\n\nbecause :\n\n$@", error => $@, data => $source) if $@;
$self->{'body'} = $code;
}