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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.