Re: union isn't finding the types

[email protected] (Ben Tilly)
Newsgroups perl.moose
Message-ID <CANoac9U7DfZ-cX1nxxqvDfXybPvw7ffxy8ncm0OUB2WutZZbhA@mail.gmail.com>
This is documented, sort of.

http://search.cpan.org/dist/Moose/lib/Moose/Manual/Types.pod#WHAT_IS_A_TYPE?

Any Moose type is automatically a type.  Any created type is a type.
Any reference to something unknown is assumed to be a type.  But the
magic breaks down when you've got complex expressions, pieces of which
are non-Moose classes.

So add in:

subtype 'Log::Any::Adaptor::Base', as 'Object', where
{$_->isa('Log::Any::Adaptor::Base')};
subtype 'Log::Any::Adapter::Null', as 'Object', where
{$_->isa('Log::Any::Adapter::Null')};

and it should work.

On Mon, Feb 18, 2013 at 3:22 PM, Caleb Cushing <[email protected]> wrote:
>
> the code,
>
> use Class::Load 0.20 'load_class';
> use Moose::Role;
>
> # VERSION
>
> #### Attribute Definitions ####
>
> has _log => (
>     isa     => 'Log::Any::Adapter::Base | Log::Any::Adapter::Null',
>     is      => 'ro',
>     lazy    => 1,
>     default => sub { load_class('Log::Any')->get_logger },
> );
>
>
> attached is the the stack trace, what about unions do I not
> understand? are they only allowed between moose native types? or am I
> doing something else that is obviously wrong?
>
>
> --
> Caleb Cushing
>
> http://xenoterracide.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.