0.51
* Moose::Role
- - add unimport so "no Moose::Role" actually does something
+ - add unimport so "no Moose::Role" actually does
+ something (sartak)
+
* Moose::Meta::Role::Application::ToRole
- when RoleA did RoleB, and RoleA aliased a method from RoleB in
order to provide its own implementation, that method still got
provide its own implementation. See Recipe 11 for an example
of all this. (thanks Dave Rolsky)
- added tests for this
+
* Moose::Meta::Method::Constructor
- when a single argument that wasn't a hashref was provided to
an immutabilized constructor, the error message was very
dew. (Thanks to Dave Rolsky)
- added test for this (also Dave Rolsky)
+ * Moose::Meta::Attribute
+ - added support for meta_attr->does("ShortAlias") (sartak)
+ - added tests for this (sartak)
+
+ * Moose::Object
+ - fix a typo in ->does (sartak)
+
0.50 Thurs. Jun 11, 2008
- Fixed a version number issue by bumping all modules
to 0.50.
predicate => 'has_applied_traits',
));
-# 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;
+# of those traits. We extend the does check to look
+# for metatrait aliases.
+sub does {
+ my ($self, $role_name) = @_;
+ my $name = eval {
+ Moose::Util::resolve_metatrait_alias(Attribute => $role_name)
+ };
+ return 0 if !defined($name); # failed to load class
+ return Moose::Object::does($self, $name);
+}
sub new {
my ($class, $name, %options) = @_;
sub does {
my ($self, $role_name) = @_;
(defined $role_name)
- || confess "You much supply a role name to does()";
+ || confess "You must supply a role name to does()";
my $meta = $self->meta;
foreach my $class ($meta->class_precedence_list) {
my $m = $meta->initialize($class);
use strict;
use warnings;
-use Test::More tests => 16;
+use Test::More tests => 24;
use Test::Exception;
use Test::Moose;
does_ok($bar_attr, 'My::Attribute::Trait');
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");
+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");
+
my $quux = My::Derived::Class->new(bar => 1000);
is($quux->bar, 1000, '... got the right value for bar');
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");
+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");
+
can_ok($quux, 'additional_method');
is(eval { $quux->additional_method }, 42, '... got the right value for additional_method');