I'm working on a legacy system with a database which has some issues. Right
now, I need to populate a Moose enum with allowable enum values from a
database. The problem is that the Moose objects don't know about the database
when they're used (or even when they're instantiated), thus making it
impossible to populate those enums.
Until we have time to fix this bug, I need a work around. It seems to me that
if I had access to class data in Moose, I could have something like this (by
the time this is called, we're guaranteed to have database access):
sub authorities {
my ( $self, $schema ) = @_;
unless ( $self->_authorities ) { # class data
$self->_authories(
# get enum values from the database
);
}
return $self->_authories;
}
This is a really nasty hack, but we simply don't have time to fix this issue
prior to our next release. However, I can't figure out how to declare a method
as a class method short of using Class::Data::Inheritable. Is there a better
way of handling this?
Cheers,
Ovid
--
Buy the book - http://www.oreilly.com/catalog/perlhks/
Tech blog - http://use.perl.org/~Ovid/journal/
Twitter - http://twitter.com/OvidPerl
Official Perl 6 Wiki - http://www.perlfoundation.org/perl6