use Mouse::Util; # enables strict and warnings
use Scalar::Util qw(blessed);
+sub _inline_slot{
+ my(undef, $self_var, $attr_name) = @_;
+ return sprintf '%s->{q{%s}}', $self_var, $attr_name;
+}
+
sub _generate_accessor{
- my (undef, $attribute, $class, $type) = @_;
+ my ($method_class, $attribute, $class, $type) = @_;
my $name = $attribute->name;
my $default = $attribute->default;
my $compiled_type_constraint = defined($constraint) ? $constraint->_compiled_type_constraint : undef;
my $self = '$_[0]';
- my $key = "q{$name}";
- my $slot = "$self\->{$key}";
+ my $slot = $method_class->_inline_slot($self, $name);;
$type ||= 'accessor';
package Mouse::Meta::Method::Constructor;
use Mouse::Util; # enables strict and warnings
+sub _inline_slot{
+ my(undef, $self_var, $attr_name) = @_;
+ return sprintf '%s->{q{%s}}', $self_var, $attr_name;
+}
+
sub _generate_constructor {
my ($class, $metaclass, $args) = @_;
}
sub _generate_processattrs {
- my ($class, $metaclass, $attrs) = @_;
+ my ($method_class, $metaclass, $attrs) = @_;
my @res;
my $has_triggers;
my $type_constraint = $attr->type_constraint;
my $need_coercion;
- my $instance_slot = "\$instance->{q{$key}}";
+ my $instance_slot = $method_class->_inline_slot('$instance', $key);
my $attr_var = "\$attrs[$index]";
my $constraint_var;