Hello
is there something like #canPerfom: or #respondsTo: in Amber? I'd like to forward some messages to a delegate, that may not understand some messages. Thanks for any help.
|
Not sure a method like that exists, but you could always do something like:
(MyClass methodAt: #methodName) notNil Although it smells like you should not be doing that... If you want to forward messages to a delegate, I think you'd better handle that in #doesNotUnderstand:
Cheers,
2011/11/10 Amber Milan Eskridge <[hidden email]> Hello Bernat Romagosa. |
Good Idea, thank you.
So you would suggest something like: [delegate update: self] on: MessageNotUnderstood do: []. ?
On Thu, Nov 10, 2011 at 6:11 PM, Bernat Romagosa <[hidden email]> wrote: Not sure a method like that exists, but you could always do something like: |
I would override #dnu:
#doesNotUnderstand: aMessage ^self delegate perform: aMessage selector withArguments: aMessage arguments Cheers, Nico On Fri, 2011-11-11 at 16:55 +0100, Amber Milan Eskridge wrote: > Good Idea, thank you. > > > > > So you would suggest something like: > > > [delegate update: self] on: MessageNotUnderstood do: []. > > > ? > > > On Thu, Nov 10, 2011 at 6:11 PM, Bernat Romagosa > <[hidden email]> wrote: > Not sure a method like that exists, but you could always do > something like: > > > (MyClass methodAt: #methodName) notNil > > > Although it smells like you should not be doing that... If you > want to forward messages to a delegate, I think you'd better > handle that in #doesNotUnderstand: > > > Cheers, > > > 2011/11/10 Amber Milan Eskridge > <[hidden email]> > Hello > > > is there something like #canPerfom: or #respondsTo: in > Amber? I'd like to forward some messages to a > delegate, that may not understand some messages. > > > Thanks for any help. > > > > > -- > Bernat Romagosa. > > > |
That's inverse to what I'd like to achieve. The delegate may not implement the methods, therefore this wouldn't help in this case. What about this?
Object>>#ifPossibleDo ^ Proxy new on: self. Proxy>>#on: anObject subject := anObject. Proxy>>#doesNotUnderstand: aMessage
^ (subject methodAt: #methodName) ifNil: [^ subject]
ifNotNil: [subject perform: aMessage selector withArguments: aMessage arguments ]
... self controller ifPossibleDo subviewMoved: aPoint. On Sat, Nov 12, 2011 at 12:37 PM, Nicolas Petton <[hidden email]> wrote: I would override #dnu: |
Free forum by Nabble | Edit this page |