Yes, pretty much exactly, except for one thing.
That could store the string in lexical variable that the instantiated role's code blocks are closed over, so it knows the value you told it.
Usually for stuff like this, I tend to prefer to make a static method to access the closed over data. Then any of my code uses the static method. It is still basically the same thing, but I prefer to not rely on closed over variables in the role block directly. (It also allows me to be really careful about my reference handling so as to avoid leaks, etc).
You may find as you delve into the world of MooseX:: that there are some plugins written in the early days of Moose which don't always take advantage of the current set of technologies. MooseX::Storage is a great example of this, it uses a hackish exported "Storage" function that will combine roles for you. If I were to write this today, I would use parameterized roles, but alas that module pre-dated MooseX::Role::Parameterized by several years and to convert it now would be a back-compat nightmare. And in the end, it still works perfectly fine so in this case, why fix something that ain't broke.
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:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||