Composing roles in the Moose class does not work

Aloha!

I have a role that I am defining in a Moose class called Authable, which essentially consists of any class that could potentially require some form of authentication in the future; this is a fairly simple role, here is the completeness:

package Trello::API::Roles::Authable;

use Moose::Role;

#authentication information
has key => (
    is => "rw",
    isa => "Str",
);

has token => (
    is => "rw",
    isa => "Str",
);

1;

For some reason, when I try to compose it into a class using several different operators, i.e. with "Trello :: API :: Roles :: Authable"; or with "Roles :: Authable";

I get the following error message: You can only consume roles, Roles::Authable is not a Moose role.

Any idea why this could be happening?

Edit

Just a side note, I checked the actual source for Moose :: Role and saw this bit:

    unless ($meta && $meta->isa('Moose::Meta::Role') ) {
        require Moose;
        Moose->throw_error( "You can only consume roles, "
                . $role->[0]
                . " is not a Moose role" );
    }

, , , - , , , . ! .

EDIT!

: , .

package Trello::API::Resource;

use Moose;
use URI::Escape;
use LWP::UserAgent;


with 'Roles::Authable';

, , , /Authable.pm, - !

+5
2

, Piers, with 'Trello::API::Roles::Authable'.

, -, , . . , - - . Moose ( MOP).

Perl , , , :

{   no strict 'refs'; 
    *{$short_pkg_name.'::'} = \*{$full_pkg_name.'::'};
};

!

. Class:: MOP , - :

Class::MOP::store_metaclass_by_name( 
       $short_pkg_name
     , Class::MOP::get_metaclass_by_name( $full_pkg_name )
     );

Perl MOP.

, , - MOP!

package Namespace::Pool;
use strict;
use warnings;
use Params::Util qw<_POSINT>;

sub import { 
    shift; # It just me.
    my $full_pkg_name = caller();
    Carp::croak( "'$full_pkg_name' is short enough!" ) 
        unless my $pool_name 
            = shift // [ split /::/, $full_pkg_name ]->[-2]
            ;
    Carp::croak( "'::$pool_name\::' not found in '$full_pkg_name'" ) 
        unless (  _POSINT( my $pos = rindex( $full_pkg_name, "::$pool_name\::" ))
               or my $is_short = _POSINT( index( $pool_name, '::' ))
               ); 
    my $short_pkg_name 
        = $is_short ? $poll_name 
        :             substr( $full_pkg_name, $pos + 2 )
        ;
    {   no strict 'refs'; 
        if ( %{$short_pkg_name.'::'} ) { 
            Carp::croak( "You have already defined $short_pkg_name!" );
        }
        *{$short_pkg_name.'::'} = \*{$full_pkg_name.'::'};
    };

    if ( my $meta = Class::MOP::get_metaclass_by_name( $full_pkg_name )) { 
        Class::MOP::store_metaclass_by_name( $short_pkg_name, $meta );
    }
    return;
}

, Role :

package Trello::API::Roles::Authable;
use strict;
use warnings;
use Moose::Role;
use Namespace::Pool 'Roles';
...

, "".

+1

"", "" , , , . d . "Testable", .

0

All Articles