Creates a new attribute in the owner class, inheriting options from parent classes.
Accessors and helper methods are installed. Some error checking is done.
-=item C<< get_read_method_ref >>\r
+=head2 C<< get_read_method_ref >>\r
\r
-=item C<< get_write_method_ref >>\r
+=head2 C<< get_write_method_ref >>\r
\r
Returns the subroutine reference of a method suitable for reading or\r
writing the attribute's value in the associated class. These methods\r
use Mouse::Meta::Module;
our @ISA = qw(Mouse::Meta::Module);
-sub method_metaclass(){ 'Mouse::Meta::Method' } # required for get_method()
+sub method_metaclass() { 'Mouse::Meta::Method' }
+sub attribute_metaclass() { 'Mouse::Meta::Attribute' }
sub _construct_meta {
my($class, %args) = @_;
$attr = $inherited_attr->clone_and_inherit_options($name, \%args);
}
else{
- my($attribute_class, @traits) = Mouse::Meta::Attribute->interpolate_class($name, \%args);
+ my($attribute_class, @traits) = $self->attribute_metaclass->interpolate_class($name, \%args);
$args{traits} = \@traits if @traits;
$attr = $attribute_class->new($name, %args);
my %METAS;
-# because Mouse doesn't introspect existing classes, we're forced to
-# only pay attention to other Mouse classes
-sub _metaclass_cache {
+sub _metaclass_cache { # DEPRECATED
my($class, $name) = @_;
return $METAS{$name};
}
# add_attribute is an abstract method
-sub get_attribute_map {
+sub get_attribute_map { # DEPRECATED
Carp::cluck('get_attribute_map() has been deprecated');
return $_[0]->{attributes};
}
# aliases as public APIs
-# it must be 'require', because Mouse::Meta::Module depends on Mouse::Util
+# it must be 'require', not 'use', because Mouse::Meta::Module depends on Mouse::Util
require Mouse::Meta::Module; # for the entities of metaclass cache utilities
BEGIN {
);
}
- sub optimized_constraints {
+ sub optimized_constraints { # DEPRECATED
Carp::cluck('optimized_constraints() has been deprecated');
return \%TYPE;
}
);
}
-sub typecast_constraints {
+sub typecast_constraints { # DEPRECATED
my($class, $pkg, $type, $value) = @_;
Carp::croak("wrong arguments count") unless @_ == 4;