Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: You cannot pass args when calling inner() in Moose?

by kennethk (Abbot)
on Jul 21, 2011 at 16:29 UTC ( [id://915922]=note: print w/replies, xml ) Need Help??


in reply to You cannot pass args when calling inner() in Moose?

But if you could pass arguments, you'd break the sub create {my $self = shift;... paradigm. Is there a reason you are not simply storing the necessary information in an attribute?

for my $item (@item) { $self->i(++$i); inner(); }

Update: Arunbear's code below works, though I'm a little thrown. This behavior is not documented in Moose::Cookbook::Basics::Recipe6 or INNER_AND_AUGMENT in Moose::Manual::MethodModifiers. Arunbear's cited source does not provide particular insight for me, but I'm no Moose expert.

Replies are listed 'Best First'.
Re^2: You cannot pass args when calling inner() in Moose?
by metaperl (Curate) on Jul 21, 2011 at 16:57 UTC
    But if you could pass arguments, you'd break the sub create {my $self = shift;... paradigm
    Yes, you have a point. I'm starting to see that Moose corrals you into keeping things in attributes instead of passing values around.
    for my $item (@item) { $self->i(++$i); inner(); }
    Ah nice. But there is a problem. There is not always an inner class... The superclass can be instatiated and run just fine if you dont plan to use perl/gtk to give GUI feedback on data processing. The inner call should only be called if ref $self ne __PACKAGE__

    Alternatively, I could always never run the superclass directly and have ::Gtk2 subclass as well as a ::PlainText subclass.



    The mantra of every experienced web application developer is the same: thou shalt separate business logic from display. Ironically, almost all template engines allow violation of this separation principle, which is the very impetus for HTML template engine development.

    -- Terence Parr, "Enforcing Strict Model View Separation in Template Engines"

Re^2: You cannot pass args when calling inner() in Moose?
by stvn (Monsignor) on Jul 22, 2011 at 02:25 UTC
    Arunbear's code below works, though I'm a little thrown.

    Actually, it doesn't. See my response.

    -stvn

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-04-19 03:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found