associated_methods. (hdp)
* Moose::Util::TypeConstraints
+ - Deprecated the totally useless Role type name, which just
+ checked if $object->can('does'). Note that this is _not_ the
+ same as a type created by calling role_type('RoleName').
+
+ * Moose::Util::TypeConstraints
* Moose::Meta::TypeConstraint::DuckType
- Reify duck type from a regular subtype into an actual class
(Sartak)
it documented here, or think we missed an important feature, please
send us a patch.
+=head1 Version 0.84
+
+The C<Role> type has been deprecated. On its own, it was useless,
+since it just checked C<< $object->can('does') >>. If you were using
+it as a parent type, just call C<role_type('Role::Name')> to create an
+appropriate type instead.
+
=head1 Version 0.78
C<use Moose::Exporter;> now imports C<strict> and C<warnings> into packages
where { blessed($_) && blessed($_) ne 'Regexp' } =>
optimize_as \&Moose::Util::TypeConstraints::OptimizedConstraints::Object;
+# This type is deprecated.
subtype 'Role' => as 'Object' => where { $_->can('does') } =>
optimize_as \&Moose::Util::TypeConstraints::OptimizedConstraints::Role;
GlobRef
FileHandle
Object
- Role
B<NOTE:> Any type followed by a type parameter C<[`a]> can be
parameterized, this means you can say:
type constraint to pass.
B<NOTE:> The C<RoleName> constraint checks a string is a I<package
-name> which is a role, like C<'MyApp::Role::Comparable'>. The C<Role>
-constraint checks that an I<object> has a C<does> method.
+name> which is a role, like C<'MyApp::Role::Comparable'>.
=head2 Type Constraint Naming
sub Object { blessed($_[0]) && blessed($_[0]) ne 'Regexp' }
-sub Role { blessed($_[0]) && $_[0]->can('does') }
+sub Role { Carp::cluck('The Role type is deprecated.'); blessed($_[0]) && $_[0]->can('does') }
sub ClassName {
return Class::MOP::is_class_loaded( $_[0] );
has 'bar' => (is => 'rw', does => 'Bar::Role');
has 'baz' => (
is => 'rw',
- does => subtype('Role', where { $_->does('Bar::Role') })
+ does => role_type('Bar::Role')
);
package Bar::Role;
use strict;
use warnings;
-use Test::More tests => 291;
+use Test::More tests => 277;
use Test::Exception;
use Scalar::Util ();
ok(defined Object(bless {}, 'Foo'), '... Object accepts anything which is blessed');
ok(!defined Object(undef), '... Object accepts anything which is blessed');
-{
- package My::Role;
- sub does { 'fake' }
-}
-
-ok(!defined Role(0), '... Role rejects anything which is not a Role');
-ok(!defined Role(100), '... Role rejects anything which is not a Role');
-ok(!defined Role(''), '... Role rejects anything which is not a Role');
-ok(!defined Role('Foo'), '... Role rejects anything which is not a Role');
-ok(!defined Role([]), '... Role rejects anything which is not a Role');
-ok(!defined Role({}), '... Role rejects anything which is not a Role');
-ok(!defined Role(sub {}), '... Role rejects anything which is not a Role');
-ok(!defined Role($SCALAR_REF), '... Role rejects anything which is not a Role');
-ok(!defined Role($GLOB_REF), '... Role rejects anything which is not a Role');
-ok(!defined Role($fh), '... Role rejects anything which is not a Role');
-ok(!defined Role(qr/../), '... Role rejects anything which is not a Role');
-ok(!defined Role(bless {}, 'Foo'), '... Role rejects anything which is not a Role');
-ok(defined Role(bless {}, 'My::Role'), '... Role accepts anything which is a Role');
-ok(!defined Role(undef), '... Role rejects anything which is not a Role');
-
ok(!defined ClassName(0), '... ClassName rejects anything which is not a ClassName');
ok(!defined ClassName(100), '... ClassName rejects anything which is not a ClassName');
ok(!defined ClassName(''), '... ClassName rejects anything which is not a ClassName');