I'm not sure if you are getting my point.

Let's say I want to model a house with 100 doors.

The Ruby code allows to call 100 times new() from class "Door" to create 100 door objects with independent states, because the methods of the mixins belong to the objects.

The shown Moose code OTOH needs 100 packages achieve this, cause all objects of such a package share the same roles. This doesn't sound very handy or scalable.

And I couldn't see any code to generate such classes, hence we have to manually name them Door1, Door2, ...Door100.

Plz correct me if I'm wrong.

Cheers Rolf

( addicted to the Perl Programming Language)

  • UPDATE 01 Jun 2013

    oops, I just realized that you already explained the mechanism behind apply_all_roles further up this thread. Sorry, I wasn't aware we are talking about the same approach.


    In reply to Re^7: a State machine with Roles - possible? (class or instance) by LanX
    in thread a State machine with Roles - possible? by mascip

    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.