T
Tim McDaniel
I'm very new to Moose, and I'm probably missing something very simple.
Does anyone have examples of code that
- provides a class attribute via MooseX::ClassAttribute
- that class attribute is readable but not changable by the outside
world
- that class attribute can be changed within the package itself?
In my case, I have a class of objects that each have an integer key
(set once at new() time, never changed thereafter). I'd like to
provide to the user of the class a way to get the minimum key so far
and the maximum key so far, but I don't want them to be able to change
it. Within the package, though, I need to conditionally update max
and min at every object creation (currently, I'm using "sub BUILD" to
catch the event).
I have a basic notion of how to do it outside Moose, but I'd like to
do it "the usual Moose|MooseX way", especially as they may handle
grungy details that I know nothing about, such as correct inheritance.
Does anyone have examples of code that
- provides a class attribute via MooseX::ClassAttribute
- that class attribute is readable but not changable by the outside
world
- that class attribute can be changed within the package itself?
In my case, I have a class of objects that each have an integer key
(set once at new() time, never changed thereafter). I'd like to
provide to the user of the class a way to get the minimum key so far
and the maximum key so far, but I don't want them to be able to change
it. Within the package, though, I need to conditionally update max
and min at every object creation (currently, I'm using "sub BUILD" to
catch the event).
I have a basic notion of how to do it outside Moose, but I'd like to
do it "the usual Moose|MooseX way", especially as they may handle
grungy details that I know nothing about, such as correct inheritance.