Class: WebMock::CallbackRegistry
- Inherits:
-
Object
- Object
- WebMock::CallbackRegistry
- Defined in:
- lib/webmock/callback_registry.rb
Constant Summary collapse
- @@callbacks =
[]
Class Method Summary collapse
- .add_callback(options, block) ⇒ Object
- .any_callbacks? ⇒ Boolean
- .callbacks ⇒ Object
- .invoke_callbacks(options, request_signature, response) ⇒ Object
- .reset ⇒ Object
Class Method Details
.add_callback(options, block) ⇒ Object
5 6 7 |
# File 'lib/webmock/callback_registry.rb', line 5 def self.add_callback(, block) @@callbacks << {options: , block: block} end |
.any_callbacks? ⇒ Boolean
30 31 32 |
# File 'lib/webmock/callback_registry.rb', line 30 def self.any_callbacks? !@@callbacks.empty? end |
.callbacks ⇒ Object
9 10 11 |
# File 'lib/webmock/callback_registry.rb', line 9 def self.callbacks @@callbacks end |
.invoke_callbacks(options, request_signature, response) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/webmock/callback_registry.rb', line 13 def self.invoke_callbacks(, request_signature, response) return if @@callbacks.empty? CallbackRegistry.callbacks.each do |callback| except = callback[:options][:except] real_only = callback[:options][:real_requests_only] unless except && except.include?([:lib]) if !real_only || [:real_request] callback[:block].call(request_signature, response) end end end end |
.reset ⇒ Object
26 27 28 |
# File 'lib/webmock/callback_registry.rb', line 26 def self.reset @@callbacks = [] end |