From: Satoshi N. <sna...@in...> - 2007-12-09 22:34:43
|
Hi, RubyCocoa defines Object.method_missing to realize a transparent =20 bridge between Ruby and Cocoa. If you redefine method_missing of a =20 class, then=10=10=10=10=10=10 the class won't respond to any ObjC = methods. That's =20 why alias_method_chain doesn't work. -- Satoshi Nakagawa On 2007/12/09, at 10:47, Marcus Crafter wrote: > Hi All, > > Hope all is going well! > > I'm trying to extend method_missing on OSX::CIImage using > alias_method_chain and are having trouble getting it to work, here's > an example to demonstrate it: > > require 'rubygems' > require 'active_support' > require 'osx/cocoa' > > module OSX > class CIImage > def method_missing_with_example(sym, *args, &block) > method_missing_without_example(sym, *args, &block) > end > > alias_method_chain :method_missing, :example > end > end > > original =3D > OSX::CIImage.imageWithContentsOfURL(OSX::NSURL.fileURLWithPath('/=20 > Users/ > crafterm/Desktop/leaves_desktop.jpg')) > puts original.extent.size > > When I run this I get: > > NoMethodError: undefined method =91extent=92 for = #<OSX::CIConcreteImage: > 0x117248c> > > If I comment out the call to alias_method_chain I get the expected > result: > > #<OSX::CGSize:0x1173710> > > Somehow alias_method_chain breaks it. This is using Ruby & RubyCocoa > as per a default install of Leopard, Rails 2.0.1 active support gems. > > Any thoughts what might be going on or what I could try to get it > working? > > Cheers, > > Marcus |