learning.moose has asked for the wisdom of the Perl Monks concerning the following question:
Hello monks.
I have a class containing text attribute, but I don't want to create printText method inside that class. I would rather create separate object that will manage my print and formatting.
This is where the problem starts. I don't want inheritance, would rather do it with roles. How can I make role read/edit fields (attributes) in a class directly, so I can do it with a code like this:
my $text = TextClass->new( text => 'some text'); $text->interfacePrint->methodPrintWithinInterface();
I dont want to pass $text->text attribute directly.
$text->interfacePrint->methodPrintWithinInterface( $text->text );^ This is how I dont want to do it
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: delete pls
by ww (Archbishop) on Apr 25, 2015 at 18:33 UTC | |
by learning.moose (Novice) on Apr 25, 2015 at 19:08 UTC | |
by choroba (Cardinal) on Apr 25, 2015 at 19:26 UTC | |
by learning.moose (Novice) on Apr 25, 2015 at 19:29 UTC | |
|
Re: Moose attribute modification
by kcott (Archbishop) on Apr 25, 2015 at 21:24 UTC | |
by learning.moose (Novice) on Apr 27, 2015 at 12:21 UTC | |
|
Re: Moose attribute modification
by CountZero (Bishop) on Apr 26, 2015 at 09:00 UTC | |
by learning.moose (Novice) on Apr 27, 2015 at 12:31 UTC | |
by Your Mother (Archbishop) on Apr 27, 2015 at 16:03 UTC | |
by CountZero (Bishop) on Apr 27, 2015 at 15:44 UTC |