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
7 8 9 |
# File 'lib/webmock/callback_registry.rb', line 7 def self.add_callback(, block) @@callbacks << {options: , block: block} end |
.any_callbacks? ⇒ Boolean
32 33 34 |
# File 'lib/webmock/callback_registry.rb', line 32 def self.any_callbacks? !@@callbacks.empty? end |
.callbacks ⇒ Object
11 12 13 |
# File 'lib/webmock/callback_registry.rb', line 11 def self.callbacks @@callbacks end |
.invoke_callbacks(options, request_signature, response) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/webmock/callback_registry.rb', line 15 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
28 29 30 |
# File 'lib/webmock/callback_registry.rb', line 28 def self.reset @@callbacks = [] end |