[Ironruby-core] override method_missing()

Lewis L. lists at ruby-forum.com
Wed Oct 19 11:24:29 EDT 2011


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


More information about the Ironruby-core mailing list