Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Moose: apply Role at Runtime (build vs. default)

by tobyink (Abbot)
on Apr 02, 2013 at 16:13 UTC ( #1026729=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    use v5.14;
    use strict;
    ...
    my $obj = "MyObject"->new;
    Moose::Util::apply_all_roles($obj, "MyRole");
    say $obj->myattr;
    
  2. or download this
    # Not this...
    default => \&_build_myattr,
    
    # This!
    default => sub { shift->_build_myattr(@_) },
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1026729]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (6)
As of 2016-12-03 16:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (56 votes). Check out past polls.