Hey all --
Recently I had a need to put together an attribute trait that causes
an attribute to expire after a certain period of time. It's fairly
straight forward (if not entirely concise), until I got to the
accessor generation part :)
I've overridden accessor_metaclass() to generate/store a new anonymous
metaclass off of the previous (generally
Moose::Meta::Method::Accessor); the accessor metaclass contains
various overrides to deal with:
* attributes having more than one slot
* inlining expiration testing and clearing
I had to override rather more of Moose::Meta::Method::Accessor than I
thought I'd need to; I'm tempted to work on a Moose topic branch that
helps refactor the inlining process a bit to make specific bits easier
to override/enhance.
This is the first time I've poked at things at this level, and while I
_think_ I did everything in the correct places, a second look would be
greatly appreciated. I know there are various bits to clean up, and I
need to think about what happens if accessors aren't inlined[1], but I
believe it's all more-or-less correct.
http://github.com/RsrchBoy/moosex-autodestruct
http://search.cpan.org/dist/MooseX-AutoDestruct/
Thanks-
-Chris
[1]
http://github.com/moose/moose/commit/f001c60fa54f30cb50c8bf6d80f472dca86ea350
--
Chris Weyl
Ex astris, scientia