Class: Pry::Method::Patcher

Inherits:
Object show all
Defined in:
lib/pry/method/patcher.rb

Constant Summary collapse

@@source_cache =
{}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method) ⇒ Patcher

Returns a new instance of Patcher


8
9
10
# File 'lib/pry/method/patcher.rb', line 8

def initialize(method)
  @method = method
end

Instance Attribute Details

#methodObject

Returns the value of attribute method


4
5
6
# File 'lib/pry/method/patcher.rb', line 4

def method
  @method
end

Class Method Details

.code_for(filename) ⇒ Object


12
13
14
# File 'lib/pry/method/patcher.rb', line 12

def self.code_for(filename)
  @@source_cache[filename]
end

Instance Method Details

#patch_in_ram(source) ⇒ Object

perform the patch


17
18
19
20
21
22
23
24
25
# File 'lib/pry/method/patcher.rb', line 17

def patch_in_ram(source)
  if method.alias?
    with_method_transaction do
      redefine source
    end
  else
    redefine source
  end
end