in reply to Re^4: Moose: What about "class" attributes?
in thread Moose: What about "class" attributes?
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.