On Sun, Mar 29, 2009 at 11:40:43AM -0400, Stevan Little wrote:
> Personally, I don't think we need to pass that meta-attribute, if you
> really want/need it, then you can do this:
>
> trigger => sub {
> my $self = shift;
> $self->meta->find_attribute_by_name('foo')->...
> ...
> }
>
> The only tricky part of the above workaround is that you need to know
> the name of the attribute in order to get the meta-attribute. But this
> shouldn't be too hard to fix/work-around in most cases.
What about passing in the attribute name instead of the meta-attribute? Then
there's no trickery necessary at all. Or a coderef that wraps up getting the
necessary objects:
sub { Moose::Util::find_meta($class_name)->get_attribute($attr_name) }
which requires closing over no objects.
hdp.