Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Role::Tiny not behaving as expected

by tangent (Parson)
on Feb 29, 2016 at 20:47 UTC ( [id://1156479]=note: print w/replies, xml ) Need Help??


in reply to Role::Tiny not behaving as expected

I think the problem is with your use of apply_roles_to_object. I did a little test and if you change the method to apply_roles_to_package it works they way you expect:
print "Using apply_roles_to_object\n"; my $test_1 = File->new; print "test_1->render\n"; $test_1->render; Role::Tiny->apply_roles_to_object($test_1, 'Draw'); print "test_1->render after apply_roles_to_object\n"; $test_1->render; print "\n\n"; print "Using apply_roles_to_package\n"; my $test_2 = File->new; print "test_2->render\n"; $test_2->render; Role::Tiny->apply_roles_to_package('File', 'Draw'); print "test_2->render after apply_roles_to_package\n"; $test_2->render;
Output:
Using apply_roles_to_object test_1->render This is package 'File' - render test_1->render after apply_roles_to_object This is package 'Draw' - render Using apply_roles_to_package test_2->render This is package 'File' - render test_2->render after apply_roles_to_package This is package 'File' - render

Replies are listed 'Best First'.
Re^2: Role::Tiny not behaving as expected
by webmistress_ming (Initiate) on Mar 01, 2016 at 11:23 UTC
    Thanks - I will try this out!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1156479]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-25 18:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found