[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

No sleep till cocoa! (works

Duncan McCaffery

8/25/2006 11:17:00 AM

Hi there I seem to have some issues with ruby cocoa and active record
can anyone help?

The following works without problems

require 'osx/cocoa'
require 'rubygems'
OSX::NSBundle.bundleWithPath("/System/Library/Frameworks/IOBluetoothUI.framework").load


But when I bring Active Record to the table...

require 'rubygems'
require_gem 'activerecord'
require 'osx/cocoa'
OSX::NSBundle.bundleWithPath("/System/Library/Frameworks/IOBluetoothUI.framework").load

ArgumentError: wrong number of arguments (0 for 1)
from (irb):4:in `load'
from (irb):4


It seems activerecord is redefining the load method in some way. I'm
fairly new to Ruby and I'm a little stuck. Any ideas? I've already
tried seperating the above into modules (active record and ruby cocoa
stuff are in seperate name spaces (I think!) but this doesn't seem to
work.

Any help would be greatly appreciated!!

Cheers,

Duncan

--
Posted via http://www.ruby-....

6 Answers

Paul Battley

8/25/2006 11:46:00 AM

0

On 25/08/06, Duncan Mccaffery <d.mccaffery@lancaster.ac.uk> wrote:
> It seems activerecord is redefining the load method in some way. I'm
> fairly new to Ruby and I'm a little stuck. Any ideas? I've already
> tried seperating the above into modules (active record and ruby cocoa
> stuff are in seperate name spaces (I think!) but this doesn't seem to
> work.

ActiveSupport is the culprit. In dependencies.rb, we find:

class Object #:nodoc:
def load(file, *extras)
super(file, *extras)
rescue Object => exception
exception.blame_file! file
raise
end
# ...

RubyCocoa works by responding to method_missing and despatching ObjC
messages via ocm_send; once ActiveSupport has had its evil (don't get
me started!) way, this will never happen.

You should be able to use this as a quick workaround:

OSX::NSBundle.bundleWithPath("...snip...").ocm_send(:load)

Paul.

Duncan McCaffery

8/25/2006 12:07:00 PM

0

Paul Battley wrote:
> On 25/08/06, Duncan Mccaffery <d.mccaffery@lancaster.ac.uk> wrote:
>> It seems activerecord is redefining the load method in some way. I'm
>> fairly new to Ruby and I'm a little stuck. Any ideas? I've already
>> tried seperating the above into modules (active record and ruby cocoa
>> stuff are in seperate name spaces (I think!) but this doesn't seem to
>> work.
>
> ActiveSupport is the culprit. In dependencies.rb, we find:
>
> class Object #:nodoc:
> def load(file, *extras)
> super(file, *extras)
> rescue Object => exception
> exception.blame_file! file
> raise
> end
> # ...
>
> RubyCocoa works by responding to method_missing and despatching ObjC
> messages via ocm_send; once ActiveSupport has had its evil (don't get
> me started!) way, this will never happen.
>
> You should be able to use this as a quick workaround:
>
> OSX::NSBundle.bundleWithPath("...snip...").ocm_send(:load)
>
> Paul.

Cheers for that everything is working fantastic!

I only wish I'd tried here about a week ago.

Thanks,

Duncan

--
Posted via http://www.ruby-....

Christian Neukirchen

8/26/2006 12:43:00 PM

0

"Paul Battley" <pbattley@gmail.com> writes:

> RubyCocoa works by responding to method_missing and despatching ObjC
> messages via ocm_send; once ActiveSupport has had its evil (don't get
> me started!) way, this will never happen.

RubyCocoa probably should use (a kind of?) BlankSlate, then?

> Paul.
--
Christian Neukirchen <chneukirchen@gmail.com> http://chneuk...

Paul Battley

8/26/2006 4:09:00 PM

0

On 26/08/06, Christian Neukirchen <chneukirchen@gmail.com> wrote:
> "Paul Battley" <pbattley@gmail.com> writes:
>
> > RubyCocoa works by responding to method_missing and despatching ObjC
> > messages via ocm_send; once ActiveSupport has had its evil (don't get
> > me started!) way, this will never happen.
>
> RubyCocoa probably should use (a kind of?) BlankSlate, then?

I don't think that would help:

class BlankSlate
instance_methods.each { |m| undef_method m unless m =~ /^__/ }
end

b = BlankSlate.new
b.load rescue p $!

#<NoMethodError: private method `load' called for #<BlankSlate:0x670858>>

require 'active_support'
b = BlankSlate.new
b.load rescue p $!

#<ArgumentError: wrong number of arguments (0 for 1)>

Paul.

Christian Neukirchen

8/27/2006 2:45:00 AM

0

"Paul Battley" <pbattley@gmail.com> writes:

> On 26/08/06, Christian Neukirchen <chneukirchen@gmail.com> wrote:
>> "Paul Battley" <pbattley@gmail.com> writes:
>>
>> > RubyCocoa works by responding to method_missing and despatching ObjC
>> > messages via ocm_send; once ActiveSupport has had its evil (don't get
>> > me started!) way, this will never happen.
>>
>> RubyCocoa probably should use (a kind of?) BlankSlate, then?
>
> I don't think that would help:
>
> class BlankSlate
> instance_methods.each { |m| undef_method m unless m =~ /^__/ }
> end
>
> b = BlankSlate.new
> b.load rescue p $!
>
> #<NoMethodError: private method `load' called for #<BlankSlate:0x670858>>
>
> require 'active_support'
> b = BlankSlate.new
> b.load rescue p $!
>
> #<ArgumentError: wrong number of arguments (0 for 1)>

You need to load blank slate after active_support...

> Paul.
--
Christian Neukirchen <chneukirchen@gmail.com> http://chneuk...

Paul Battley

8/27/2006 7:56:00 AM

0

On 27/08/06, Christian Neukirchen <chneukirchen@gmail.com> wrote:
> You need to load blank slate after active_support...

D'oh! Of course.

Paul.