Compose-time hooks (was: hashref instead of objects)

[email protected] (Robert 'phaylon' Sedlacek)
Newsgroups perl.moose
Message-ID <[email protected]>
Ricardo SIGNES wrote:

> Hm.  What I really want is Role->meta->all_classes_composing, but that's
> not the worst thing ever.  I'd rather have it work magically, but I can 
> deal with three lines for the sake of great justice!

Reminds me that I always wanted some sort of COMPOSE hook for roles. In this
case, it would probably work like

  package My::Role;
  use Moose::Role;
  use Moose::Util::TypeConstraints;

  sub COMPOSE {
    my ($consumer) = @_;
    coerce $consumer, from 'HashRef', via { $consumer->new($_) };
  }

  1;


-rs
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.