[Ironruby-core] override method_missing()

Tomas Matousek Tomas.Matousek at microsoft.com
Wed Oct 19 12:11:02 EDT 2011


Might be a bug.

-----Original Message-----
From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Lewis L.
Sent: Wednesday, October 19, 2011 8:24 AM
To: ironruby-core at rubyforge.org
Subject: [Ironruby-core] override method_missing()

Hi,
Is there a way to override the method_missing method and keep the SetVariable lookup behavior from ScriptScope?
For example,

in C#
aScriptScope.SetVariable("a", "some_value")

in Ruby
p a
=> "some_value"

But if I do,

class << self
  def method_missing(sym, *args, &block)
    case (sym)
    when :some_case
       do_something
    else
       super #try to fallback to the original
    end
  end
end

or

class << self
  alias :old_method_missing :method_missing
  def method_missing(sym, *args, &block)
    case (sym)
    when :some_case
       do_something
    else
       old_method_missing(sym, *args, &block) #try to fallback to the original
    end
  end
end

p a
=> NameError: undefined local variable or method 'a' for main:Object

--
Posted via http://www.ruby-forum.com/.
_______________________________________________
Ironruby-core mailing list
Ironruby-core at rubyforge.org
http://rubyforge.org/mailman/listinfo/ironruby-core






More information about the Ironruby-core mailing list