}
sub interpolate_class{
- my($class, $name, $args) = @_;
+ my($class, $args) = @_;
if(my $metaclass = delete $args->{metaclass}){
$class = Mouse::Util::resolve_metaclass_alias( Attribute => $metaclass );
}
if (@traits) {
- warn "traits [@traits] for $class\n";
$class = Mouse::Meta::Class->create_anon_class(
superclasses => [ $class ],
roles => \@traits,
}
sub clone_and_inherit_options{
- my $self = shift;
- my $name = shift;
+ my($self, %args) = @_;
+
+ my($attribute_class, @traits) = ref($self)->interpolate_class(\%args);
- return ref($self)->new($name, %{$self}, (@_ == 1) ? %{$_[0]} : @_);
+ $args{traits} = \@traits if @traits;
+ return $attribute_class->new($self->name, %{$self}, %args);
}
sub clone_parent { # DEPRECATED
if ($name =~ s/^\+//) { # inherited attributes
my $inherited_attr;
+ # find_attribute_by_name
foreach my $class($self->linearized_isa){
my $meta = Mouse::Util::get_metaclass_by_name($class) or next;
$inherited_attr = $meta->get_attribute($name) and last;
defined($inherited_attr)
or $self->throw_error("Could not find an attribute by the name of '$name' to inherit from in ".$self->name);
- $attr = $inherited_attr->clone_and_inherit_options($name, \%args);
+ $attr = $inherited_attr->clone_and_inherit_options(%args);
}
else{
- my($attribute_class, @traits) = $self->attribute_metaclass->interpolate_class($name, \%args);
+ my($attribute_class, @traits) = $self->attribute_metaclass->interpolate_class(\%args);
$args{traits} = \@traits if @traits;
$attr = $attribute_class->new($name, %args);
is($bar_attr->foo, "blah", "attr initialized");
ok(!$bar_attr->meta->does_role('Aliased'), "does_role ignores aliases for sanity");
-ok($bar_attr->does('Aliased'), "attr->does uses aliases");
+{
+ local $TODO = 'Mouse does not support ->does($aliased)';
+ ok($bar_attr->does('Aliased'), "attr->does uses aliases");
+}
ok(!$bar_attr->meta->does_role('Fictional'), "does_role returns false for nonexistent roles");
ok(!$bar_attr->does('Fictional'), "attr->does returns false for nonexistent roles");
is($derived_bar_attr->the_other_attr, "oink", "attr initialized" );
ok(!$derived_bar_attr->meta->does_role('Aliased'), "does_role ignores aliases for sanity");
-ok($derived_bar_attr->does('Aliased'), "attr->does uses aliases");
+{
+ local $TODO = 'Mouse does not support ->does($aliased)';
+ ok($derived_bar_attr->does('Aliased'), "attr->does uses aliases");
+}
ok(!$derived_bar_attr->meta->does_role('Fictional'), "does_role returns false for nonexistent roles");
ok(!$derived_bar_attr->does('Fictional'), "attr->does returns false for nonexistent roles");