No sleep till cocoa! (works)

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-forum.com/.

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.

···

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.

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-forum.com/.

"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://chneukirchen.org

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.

···

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?

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

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

···

On 26/08/06, Christian Neukirchen <chneukirchen@gmail.com> wrote:

Paul.

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

D'oh! Of course.

Paul.

···

On 27/08/06, Christian Neukirchen <chneukirchen@gmail.com> wrote:

You need to load blank slate after active_support...