have slightly better support for AUTOLOADed
objects
- added more delegation tests
+ - adding ->does method to this so as to better
+ support traits and their introspection.
+ - added tests for this
* Moose::Object
- localizing the Data::Dumper configurations so
predicate => 'has_documentation',
));
+# NOTE:
+# we need to have a ->does method in here to
+# more easily support traits, and the introspection
+# of those traits. So in order to do this we
+# just alias Moose::Object's version of it.
+# - SL
+*does = \&Moose::Object::does;
+
sub new {
my ($class, $name, %options) = @_;
$class->_process_options($name, \%options);
|| confess "You much supply a role name to does()";
my $meta = $self->meta;
foreach my $class ($meta->class_precedence_list) {
+ my $m = $meta->initialize($class);
return 1
- if $meta->initialize($class)->does_role($role_name);
+ if $m->can('does_role') && $m->does_role($role_name);
}
return 0;
}
use strict;
use warnings;
-use Test::More tests => 6;
+use Test::More tests => 8;
use Test::Exception;
use Test::Moose;
isa => 'Int',
alias_to => 'baz',
);
+
+ has 'gorch' => (
+ is => 'ro',
+ isa => 'Int',
+ default => sub { 10 }
+ );
}
my $c = My::Class->new(bar => 100);
isa_ok($c, 'My::Class');
is($c->bar, 100, '... got the right value for bar');
+is($c->gorch, 10, '... got the right value for gorch');
can_ok($c, 'baz');
is($c->baz, 100, '... got the right value for baz');
does_ok($c->meta->get_attribute('bar'), 'My::Attribute::Trait');
+ok(!$c->meta->get_attribute('gorch')->does('My::Attribute::Trait'), '... gorch doesnt do the trait');