Module: Spy::API
- Included in:
- Spy
- Defined in:
- lib/spy/api.rb
Instance Method Summary collapse
-
#on(*args) ⇒ Object
Initializes a new spy instance for the method.
-
#on_any_instance(mod, msg) ⇒ Object
TODO docs.
-
#restore(*args) ⇒ Object
Stops spying on the method and restores its original functionality.
Instance Method Details
#on(*args) ⇒ Object
Initializes a new spy instance for the method
With two args:
10 11 12 13 14 15 16 |
# File 'lib/spy/api.rb', line 10 def on(*args) case args.length when 2 return core.add_spy *(args << :method) end raise ArgumentError end |
#on_any_instance(mod, msg) ⇒ Object
TODO docs
19 20 21 |
# File 'lib/spy/api.rb', line 19 def on_any_instance(mod, msg) core.add_spy(mod, msg, :instance_method) end |
#restore(*args) ⇒ Object
Stops spying on the method and restores its original functionality
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/spy/api.rb', line 35 def restore(*args) case args.length when 1 return core.remove_all_spies if args.first == :all when 2 return core.remove_spy *(args << :method) when 3 return core.remove_spy *args end raise ArgumentError end |