106
107
108
109
110
111
112
113
114
115
116
|
# File 'lib/cop.rb', line 106
def adapt_class(a_class, a_selector, a_method)
begin
method = a_class.instance_method(a_selector)
rescue NameError
raise Exception, "can't adapt inexistent method #{a_selector.to_s} in #{a_method.to_s}"
end
default = ContextAdaptation.in_context(Context.default, a_class, a_selector, method)
Context.default.add_adaptation(default) { :preserve }
adaptation = ContextAdaptation.in_context(self, a_class, a_selector, a_method)
self.add_adaptation(adaptation) { raise Exception, "an adaptation already exists for #{self.to_s}" }
end
|