Class: Forewarn::OverridesMethods

Inherits:
Object
  • Object
show all
Defined in:
lib/forewarn/overrides_methods.rb

Instance Method Summary collapse

Instance Method Details

#override!(methods) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/forewarn/overrides_methods.rb', line 5

def override!(methods)
  triggers_warning = TriggersWarning.new
  methods.each do |method|
    real_method = method.method
    real_method.owner.send(:define_method, real_method.name) do |*args, &blk|
      triggers_warning.trigger!(method, caller_locations(1,1)[0].to_s)
      method.bind(self).call(*args, &blk)
    end
  end
end