Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
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?
[Happy-the-monk]: LanX: for what? Being more successful selling old stories than her antecedents?
[Happy-the-monk]: (now all you need to do is answer: "no, for money." ;-))

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2018-04-20 11:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?