Thank you very much for your comment!

I'll try to explain why exactly I need to have access to the object that has initialized the current object (that's what I mean when I call it "the parent object"). For example, let's imagine we have some class for the jobs-queue runner (let's call it SomeFramework::JobsQueue::Executor) and some class for jobs. Is it bad to do something like this:

package SomeFramework::JobsQueue::Executor; use Moose; use MooseX::Params::Validate; has queue { isa => 'SomeFramework::JobsQueue', required => 1, reader => 'get_queue', writer => '_set_queue' } # This attribute is being set by the framework when the framework # creates the SomeFramework::JobsQueue::Runner-based object sub execute { my($self, $job, $options) = validated_hash( \@_, job => { isa => 'SomeFramework::JobsQueue::Job' }, options => { isa => 'HashRef' } ); my $queue = $self->get_queue; $queue->mark_as_running($job->get_id); $job->execute(options => $options); $queue->mark_as_completed($job->get_id); }

? So, the queue-runner object is aware about the queue object it "belongs" to, so it can call some methods of the queue object.

Or let's look at much more simple example:

package SomeFramework::SomeSubsystem; use Moose; has 'some_framework' => { isa => 'SomeFramework', required => 1, reader => 'get_some_framework', writer => '_set_some_framework' } sub some_method { my $self = shift; $self->get_some_framework->get_logger->log_trace("Hello, world!"); }

So, our object knows how to call the framework's object that has initialized that object, so it can call some methods of the framework's object and even some methods of other objects initialized and stored by the framework's object.

If it's really bad, would you be so kind as to help me to understand why? Thank you!

V.Melnik

In reply to Re^2: Names of attribute accessors (Moose) by v_melnik
in thread Names of attribute accessors (Moose) by v_melnik

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.