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 throw_error {
+ my $self = shift;
+ my $class = ( ref $self && $self->associated_class ) || "Moose::Meta::Class";
+ unshift @_, "message" if @_ % 2 == 1;
+ unshift @_, attr => $self if ref $self;
+ unshift @_, $class;
+ goto $class->can("throw_error"); # to avoid incrementing depth by 1
+}
+
sub new {
my ($class, $name, %options) = @_;
$class->_process_options($name, \%options) unless $options{__hack_no_process_options}; # used from clone()... YECHKKK FIXME ICKY YUCK GROSS
if (exists $options->{is}) {
- =pod
-
- is => ro, writer => _foo # turns into (reader => foo, writer => _foo) as before
- is => rw, writer => _foo # turns into (reader => foo, writer => _foo)
- is => rw, accessor => _foo # turns into (accessor => _foo)
- is => ro, accessor => _foo # error, accesor is rw
-
- =cut
+ ### -------------------------
+ ## is => ro, writer => _foo # turns into (reader => foo, writer => _foo) as before
+ ## is => rw, writer => _foo # turns into (reader => foo, writer => _foo)
+ ## is => rw, accessor => _foo # turns into (accessor => _foo)
+ ## is => ro, accessor => _foo # error, accesor is rw
+ ### -------------------------
if ($options->{is} eq 'ro') {
- confess "Cannot define an accessor name on a read-only attribute, accessors are read/write"
+ $class->throw_error("Cannot define an accessor name on a read-only attribute, accessors are read/write", data => $options)
if exists $options->{accessor};
$options->{reader} ||= $name;
}