W3C home > Mailing lists > Public > public-rdf-ruby@w3.org > May 2011

Re: Spira: method resolution of has_many resources not working sometimes

From: Christoph Badura <bad@bsd.de>
Date: Wed, 25 May 2011 18:58:55 +0200
To: public-rdf-ruby@w3.org
Cc: Ben Lavender <ben@dydra.com>
Message-ID: <20110525165855.GK8151@irregular-apocalypse.k.bsd.de>
I have looked more into this over the last days.  

On Fri, May 20, 2011 at 12:11:10PM -0500, Ben Lavender wrote:
> This is a quirk of Promise. In Ruby 1.8, there is no BasicObject, so
> Promise fakes it by undefining all of the non-critical methods on
> Object. 

This is a part that actually fails in 1.8.7.  The reason is that
instance_methods() returns an array of strings in 1.8 and an array of symbols
in 1.9.  And undef_methods silently fails if passed a string instead of a


  instance_methods.each { |m| undef_method m.to_sym unless m.to_s =~ /__/ }
in promise.rb brings us forward a big step to a solution.

The other thing is that the test case is wrong for 1.8.7.  Promise must
be required *after* Object has been modified because it only undefs the
instance methods that are defined on Object when promise.rb is executed.

class Object
  def to_zorch
    "promises can't be zorched!"

require 'promise'

class Fixnum
  def to_zorch
x = promise { 15 }

With the above change to promise.rb I now get '15' on 1.8.7 too.

Of course, this does not produce exactly the same behaviour as under 1.9.x.
A quick test suggests it may be enough to make Spira and Rails work on 1.8.7.

Received on Wednesday, 25 May 2011 16:59:19 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 19:53:41 UTC