Problems? Is your data what you think it is? | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Your override can be written more simply:
As you're potentially not creating a new object, but returning a cached object, I don't think Class->instance(%args) is a bad name for the method call. new would be a misnomer.
No, you wouldn't need to change all the calls. You'd just need to change the instance method to always return a new object:
One of the things I'm encouraging in Zydeco is the idea that the new method should be considered internal to the class, and the class should provide factory methods for external code to call. And it's for this kind of reason — it allows the class to do things like return cached objects, or a singleton, or whatever. In reply to Re: Override new in Moose for flyweight objects
by tobyink
|
|