Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2014-07-11 22:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (235 votes), past polls