Class: Spy::Instance::Strategy::Intercept
- Inherits:
-
Object
- Object
- Spy::Instance::Strategy::Intercept
- Defined in:
- lib/spy/instance/strategy/intercept.rb
Instance Method Summary collapse
- #apply ⇒ Object
-
#initialize(spy, intercept_target) ⇒ Intercept
constructor
A new instance of Intercept.
- #undo ⇒ Object
Constructor Details
#initialize(spy, intercept_target) ⇒ Intercept
Returns a new instance of Intercept.
5 6 7 8 |
# File 'lib/spy/instance/strategy/intercept.rb', line 5 def initialize(spy, intercept_target) @spy = spy @intercept_target = intercept_target end |
Instance Method Details
#apply ⇒ Object
10 11 12 |
# File 'lib/spy/instance/strategy/intercept.rb', line 10 def apply @spy.attach_to(@intercept_target) end |
#undo ⇒ Object
14 15 16 17 18 19 |
# File 'lib/spy/instance/strategy/intercept.rb', line 14 def undo spy = @spy @intercept_target.class_eval do remove_method spy.original.name end end |