Stevan Little wrote:
> Christoph,
>
> I don't see any reason why trigger couldn't also take a method name  as
> well as a CODE ref.
>
> However, in your example below, you pass $_[2] into &change, where $_
> [2] is the attribute metaobject for  'pub_in_a_TkObjectsModel_Instance'.
> This would not be the common  behavior most people would expect I think.

I skipped $_[1], because in my case I didn't need the value. It should of course be in there for a general solution.

>
> I would be more inclined to do something like:
>
>   trigger => 'changed'
>
> then trigger would be expanded into this by Moose:
>
>   trigger => sub { (shift)->changed(@_) }
>
> which may or may not always do what you want.

This would be the most natural behaviour. - And if that was not sufficient, we could still pass a coderef...




Christoph

>
> I think Matt Trout may have already implemented a similar feature in
> Reaction.

> On Jun 4, 2007, at 5:25 PM, Ch Lamprecht wrote:

>> I was trying to use a method of my class as 'trigger' in an
>> attributes definition. Here is what I wrote:
>>

>>      trigger => sub{$_[0] -> changed($_[2])},
>>
>>
>> That works fine. However, are there more elegant solutions?  Wouldn't
>> it be a nice feature, if we could say:
>>
>> ...
>> trigger => 'changed',
>> ...

Reply via email to