weaken( $attr->{associated_class} = $self );
- $self->{attributes}{$attr->name} = $attr;
+ # install accessors first
$attr->install_accessors();
+ # then register the attribute to the metaclass
+ $attr->{insertion_order} = keys %{ $self->{attributes} };
+ $self->{attributes}{$attr->name} = $attr;
+
if(!$attr->{associated_methods} && ($attr->{is} || '') ne 'bare'){
Carp::carp(qq{Attribute ($name) of class }.$self->name
.qq{ has no associated methods (did you mean to provide an "is" argument?)});
sub linearized_isa;
sub new_object;
+sub clone_object;
-sub clone_object {
- my $class = shift;
- my $object = shift;
- my $args = $object->Mouse::Object::BUILDARGS(@_);
-
- (blessed($object) && $object->isa($class->name))
- || $class->throw_error("You must pass an instance of the metaclass (" . $class->name . "), not ($object)");
-
- my $cloned = bless { %$object }, ref $object;
- $class->_initialize_object($cloned, $args, 1);
-
- return $cloned;
-}
sub clone_instance { # DEPRECATED
my ($class, $instance, %params) = @_;
$self->{is_immutable}++;
- $self->{strict_constructor} = $args{strict_constructor};
-
if ($args{inline_constructor}) {
$self->add_method($args{constructor_name} =>
Mouse::Util::load_class($self->constructor_class)
sub _install_modifier {
my ( $self, $type, $name, $code ) = @_;
- # load Class::Method::Modifiers first
+ # load Data::Util first
my $no_cmm_fast = do{
local $@;
- eval q{ use Class::Method::Modifiers::Fast 0.041 () };
+ eval q{ use Data::Util 0.55 () };
$@;
};
$impl = \&_install_modifier_pp;
}
else{
- my $install_modifier = Class::Method::Modifiers::Fast->can('install_modifier');
$impl = sub {
my ( $self, $type, $name, $code ) = @_;
my $into = $self->name;
- $install_modifier->($into, $type, $name, $code);
- $self->add_method($name => Mouse::Util::get_code_ref($into, $name));
+ my $method = Mouse::Util::get_code_ref( $into, $name );
+
+ if ( !$method || !Data::Util::subroutine_modifier($method) ) {
+ unless ($method) {
+ $method = $into->can($name)
+ or Carp::confess("The method '$name' is not found in the inheritance hierarchy for class $into");
+ }
+ $method = Data::Util::modify_subroutine( $method,
+ $type => [$code] );
+
+ $self->add_method($name => $method);
+ }
+ else {
+ Data::Util::subroutine_modifier( $method, $type => $code );
+ $self->add_method($name => Mouse::Util::get_code_ref($into, $name));
+ }
+
return;
};
}
=head1 VERSION
-This document describes Mouse version 0.58
+This document describes Mouse version 0.64
=head1 METHODS