Module: Switchman::CallSuper

Defined in:
lib/switchman/call_super.rb

Instance Method Summary collapse

Instance Method Details

#call_super(method, above_module, *args, &block) ⇒ Object



15
16
17
# File 'lib/switchman/call_super.rb', line 15

def call_super(method, above_module, *args, &block)
  super_method_above(method, above_module).call(*args, &block)
end

#super_method_above(method_name, above_module) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/switchman/call_super.rb', line 5

def super_method_above(method_name, above_module)
  method = method(method_name)
  last_owner = method.owner
  while method.owner != above_module
    method = method.super_method
    raise "Could not find super method ``#{method_name}' for #{self.class}" if method.owner == last_owner
  end
  method.super_method
end