No sleep till cocoa! (works)

D

Duncan Mccaffery

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
 
P

Paul Battley

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.
 
D

Duncan Mccaffery

Paul said:
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
 
P

Paul Battley

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top