writer => 'Class::MOP::Method::Writer',
predicate => 'Class::MOP::Method::Predicate',
clearer => 'Class::MOP::Method::Clearer',
+ accessor => 'Class::MOP::Method::Accessor',
}
}
$method_ctx->{description} = $desc;
}
- my $method_metaclass = $self->method_metaclasses->{$type} || $self->accessor_metaclass;
+ my $method_metaclass = $self->method_metaclasses->{$type};
$method = $method_metaclass->new(
attribute => $self,
is_inline => $inline_me,
- accessor_type => $type,
package_name => $self->associated_class->name,
name => $accessor,
definition_context => $method_ctx,
my $method_name = join "_" => (
'_generate',
- $self->accessor_type,
'method',
($self->is_inline ? 'inline' : ())
);
## generators
-sub _generate_accessor_method {
- my $attr = (shift)->associated_attribute;
- return sub {
- $attr->set_value($_[0], $_[1]) if scalar(@_) == 2;
- $attr->get_value($_[0]);
- };
+sub generate_method {
+ Carp::cluck('The generate_accessor_method method has been made private.'
+ . " The public version is deprecated and will be removed in a future release.\n");
+ shift->_generate_method;
}
-sub _generate_reader_method {
+sub _generate_method {
my $attr = (shift)->associated_attribute;
return sub {
- confess "Cannot assign a value to a read-only accessor" if @_ > 1;
+ $attr->set_value($_[0], $_[1]) if scalar(@_) == 2;
$attr->get_value($_[0]);
};
}
+## Inline methods
-sub _generate_writer_method {
- my $attr = (shift)->associated_attribute;
- return sub {
- $attr->set_value($_[0], $_[1]);
- };
-}
-
-sub _generate_predicate_method {
- my $attr = (shift)->associated_attribute;
- return sub {
- $attr->has_value($_[0])
- };
-}
-
-sub _generate_clearer_method {
- my $attr = (shift)->associated_attribute;
- return sub {
- $attr->clear_value($_[0])
- };
+sub generate_method_inline {
+ Carp::cluck('The generate_accessor_method_inline method has been made private.'
+ . " The public version is deprecated and will be removed in a future release.\n");
+ shift->_generate_method_inline;
}
-## Inline methods
-
-sub _generate_accessor_method_inline {
+sub _generate_method_inline {
my $self = shift;
my $attr = $self->associated_attribute;
my $attr_name = $attr->name;
return $code;
}
-sub _generate_reader_method_inline {
- my $self = shift;
- my $attr = $self->associated_attribute;
- my $attr_name = $attr->name;
- my $meta_instance = $attr->associated_class->instance_metaclass;
-
- my ( $code, $e ) = $self->_eval_closure(
- {},
- 'sub {'
- . 'confess "Cannot assign a value to a read-only accessor" if @_ > 1;'
- . $meta_instance->inline_get_slot_value('$_[0]', $attr_name)
- . '}'
- );
- confess "Could not generate inline reader because : $e" if $e;
-
- return $code;
-}
-
-sub _generate_writer_method_inline {
- my $self = shift;
- my $attr = $self->associated_attribute;
- my $attr_name = $attr->name;
- my $meta_instance = $attr->associated_class->instance_metaclass;
-
- my ( $code, $e ) = $self->_eval_closure(
- {},
- 'sub {'
- . $meta_instance->inline_set_slot_value('$_[0]', $attr_name, '$_[1]')
- . '}'
- );
- confess "Could not generate inline writer because : $e" if $e;
-
- return $code;
-}
-
-sub _generate_predicate_method_inline {
- my $self = shift;
- my $attr = $self->associated_attribute;
- my $attr_name = $attr->name;
- my $meta_instance = $attr->associated_class->instance_metaclass;
-
- my ( $code, $e ) = $self->_eval_closure(
- {},
- 'sub {'
- . $meta_instance->inline_is_slot_initialized('$_[0]', $attr_name)
- . '}'
- );
- confess "Could not generate inline predicate because : $e" if $e;
-
- return $code;
-}
-
-sub _generate_clearer_method_inline {
- my $self = shift;
- my $attr = $self->associated_attribute;
- my $attr_name = $attr->name;
- my $meta_instance = $attr->associated_class->instance_metaclass;
-
- my ( $code, $e ) = $self->_eval_closure(
- {},
- 'sub {'
- . $meta_instance->inline_deinitialize_slot('$_[0]', $attr_name)
- . '}'
- );
- confess "Could not generate inline clearer because : $e" if $e;
-
- return $code;
-}
-
1;
# XXX - UPDATE DOCS