I think it comes down to this: module methods should show up in the public_instance_methods of the module.

C:\rails>jruby -e "p ::Kernel.public_instance_methods.sort"
[]

C:\rails>ruby -e "p :: Kernel.public_instance_methods.sort"
["==", "===", "=~", "__id__", "__send__", "class", "clone", "display", "dup", "eql?", "equal?", "extend", "freeze", "frozen?", "ha
sh", "id", "inspect", "instance_eval", "instance_of?", "instance_variable_get", "instance_variable_set", "instance_variables", "is
_a?", "kind_of?", "method", "methods", "nil?", "object_id", "private_methods", "protected_methods", "public_methods", "require", "
require_gem", "require_gem_with_options", "respond_to?", "send", "singleton_methods", "taint", "tainted?", "to_a", "to_s", "type",
 "untaint"]

The DelegateClass determines the methods provided by the delegatee by substracting Kernel's public_instance_methods from the delegatee's public_instance_methods. Since in JRuby, Kernel is shown to have no public_instance_methods, the DelegateClass ends up assuming we want to call the "send" on the delegatee, and so it is never sent to the current class.

- Charlie

On 3/16/06, Charles O Nutter <[EMAIL PROTECTED]> wrote:
I narrowed down my current Rails issue to something wrong with how we handle self and send in the context of DelegateClass. I have not dug deeper than this yet.

The following succeeded in Ruby, fails in JRuby:

require 'delegate'

class Foo
end

class Bar < DelegateClass(Foo)
  def bar
    puts "bar"
  end

  def doit
    self.send(:bar)
  end
end

f = Foo.new
b = Bar.new (f)

b.doit

--
Charles Oliver Nutter @ headius.blogspot.com
JRuby Developer @ jruby.sourceforge.net
Application Architect @ www.ventera.com



--
Charles Oliver Nutter @ headius.blogspot.com
JRuby Developer @ jruby.sourceforge.net
Application Architect @ www.ventera.com

Reply via email to