use strict;
use warnings;
-our $VERSION = '0.57';
+our $VERSION = '0.68';
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
use base 'Moose::Meta::Method',
'Class::MOP::Method::Accessor';
-## Inline method generators
+sub _error_thrower {
+ my $self = shift;
+ ( ref $self && $self->associated_attribute ) || $self->SUPER::_error_thrower();
+}
sub _eval_code {
my ( $self, $code ) = @_;
# NOTE:
# set up the environment
- my $attr = $self->associated_attribute;
- my $attr_name = $attr->name;
- 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
+ my $attr = $self->associated_attribute;
+ my $type_constraint_obj = $attr->type_constraint;
+ my $environment = {
+ '$attr' => \$attr,
+ '$attr_name' => \$attr->name,
+ '$meta' => \$self,
+ '$type_constraint_obj' => \$type_constraint_obj,
+ '$type_constraint_name' => \($type_constraint_obj && $type_constraint_obj->name),
+ '$type_constraint' => \($type_constraint_obj
? $type_constraint_obj->_compiled_type_constraint
- : undef;
+ : 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 $@;
- return $sub;
-
+ $self->_compile_code( environment => $environment, code => $code )
+ or $self->throw_error("Could not create writer for '${\$self->associated_attribute->name}' because $@ \n code: $code", error => $@, data => $code );
}
sub generate_accessor_method_inline {
sub generate_reader_method { shift->generate_reader_method_inline(@_) }
sub generate_writer_method { shift->generate_writer_method_inline(@_) }
sub generate_accessor_method { shift->generate_accessor_method_inline(@_) }
+sub generate_predicate_method { shift->generate_predicate_method_inline(@_) }
+sub generate_clearer_method { shift->generate_clearer_method_inline(@_) }
sub _inline_pre_body { '' }
sub _inline_post_body { '' }
my ($self, $instance, $value) = @_;
my $attr = $self->associated_attribute;
return '' unless $attr->has_trigger;
- return sprintf('$attr->trigger->(%s, %s, $attr);', $instance, $value);
+ return sprintf('$attr->trigger->(%s, %s);', $instance, $value);
}
sub _inline_get {
=item B<generate_writer_method>
+=item B<generate_predicate_method>
+
+=item B<generate_clearer_method>
+
=item B<generate_accessor_method_inline>
=item B<generate_reader_method_inline>
=head1 COPYRIGHT AND LICENSE
-Copyright 2006-2008 by Infinity Interactive, Inc.
+Copyright 2006-2009 by Infinity Interactive, Inc.
L<http://www.iinteractive.com>