94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
# File 'lib/monkey_bars/patch.rb', line 94
def super_super(*args, **kwargs)
caller_line = caller(1..1).first
calling_method_name = caller_line[/in [`'](.*?)[`']/, 1] || caller_line[/in (.*?)$/, 1]
raise "Could not determine calling method name from: #{caller_line}" if calling_method_name.nil?
if is_a?(Class)
unless superclass.respond_to?(:singleton_method) && superclass.singleton_methods.include?(calling_method_name.to_sym)
raise NoMethodError, "undefined method `#{calling_method_name}' for class `#{superclass}'"
end
superclass.singleton_method(calling_method_name).call(*args, **kwargs)
else
unless self.class.superclass&.method_defined?(calling_method_name.to_sym)
raise(NoMethodError, "undefined method `#{calling_method_name}' for class `#{self.class.superclass}'")
end
self.class.superclass.instance_method(calling_method_name).bind_call(self, *args, **kwargs)
end
end
|