MooseX::ClassAttribute: read-only outside, writable inside

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top