Class: Dcr::InstanceMethodHistory
- Inherits:
-
History
- Object
- History
- Dcr::InstanceMethodHistory
show all
- Defined in:
- lib/dcr/instance_method_history.rb
Instance Attribute Summary
Attributes inherited from History
#track
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from History
#add_to_track, #caller_not_from_dcr, #initialize, #list, of, #pop_all_track, #pop_last_track, #warn_if_no_org_methods
Constructor Details
This class inherits a constructor from Dcr::History
Class Method Details
.ivar ⇒ Object
5
6
7
|
# File 'lib/dcr/instance_method_history.rb', line 5
def self.ivar
:@_dcr_im
end
|
Instance Method Details
#commit(method_name, &decorator) ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/dcr/instance_method_history.rb', line 13
def commit method_name, &decorator
unbound_org_method = klass.instance_method method_name
new_method = lambda do |*args|
bound_method = unbound_org_method.bind self
decorator.call bound_method, *args
end
klass.class_eval do
define_method method_name, &new_method
end
add_to_track unbound_org_method
end
|
#klass ⇒ Object
9
10
11
|
# File 'lib/dcr/instance_method_history.rb', line 9
def klass
@object
end
|
#rollback(method_name) ⇒ Object
28
29
30
31
|
# File 'lib/dcr/instance_method_history.rb', line 28
def rollback method_name
org_method = pop_last_track method_name
klass.send :define_method, method_name, org_method
end
|
#rollback_all(method_name) ⇒ Object
33
34
35
36
|
# File 'lib/dcr/instance_method_history.rb', line 33
def rollback_all method_name
org_method = pop_all_track method_name
klass.send :define_method, method_name, org_method
end
|