Module: MonkeyPatcherPatcher::ClassMethods

Defined in:
lib/monkey_patcher_patcher.rb

Instance Method Summary collapse

Instance Method Details

#method_added(method_name) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/monkey_patcher_patcher.rb', line 10

def method_added(method_name)
  return if @_monkey_patcher_at_work

  @_monkey_patcher_patcher_methods ||= []
  if @_monkey_patcher_patcher_methods.include?("#{method_name}")
    monkey_patcher_alias_method_name = "_monkey_patcher_patcher_alias_#{method_name}"

    class_eval do
      @_monkey_patcher_at_work = true
      alias_method method_name.to_sym, monkey_patcher_alias_method_name.to_sym
      @_monkey_patcher_at_work = false
    end
  end
end

#monkey_patcher_patcher(*method_names) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/monkey_patcher_patcher.rb', line 25

def monkey_patcher_patcher(*method_names)
  @_monkey_patcher_patcher_methods ||= []      
  @_monkey_patcher_patcher_method_aliases ||= {}

  method_names.each do |method_name|
    @_monkey_patcher_patcher_methods << "#{method_name}"
    monkey_patcher_alias_method_name = "_monkey_patcher_patcher_alias_#{method_name}"

    class_eval do
      alias_method monkey_patcher_alias_method_name.to_sym, method_name.to_sym
    end
  end
end