Class: WebMock::CallbackRegistry

Inherits:
Object
  • Object
show all
Defined in:
lib/webmock/callback_registry.rb

Constant Summary collapse

@@callbacks =
[]

Class Method Summary collapse

Class Method Details

.add_callback(options, block) ⇒ Object



7
8
9
# File 'lib/webmock/callback_registry.rb', line 7

def self.add_callback(options, block)
  @@callbacks << {options: options, block: block}
end

.any_callbacks?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/webmock/callback_registry.rb', line 32

def self.any_callbacks?
  !@@callbacks.empty?
end

.callbacksObject



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(options, 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?(options[:lib])
      if !real_only || options[:real_request]
        callback[:block].call(request_signature, response)
      end
    end
  end
end

.resetObject



28
29
30
# File 'lib/webmock/callback_registry.rb', line 28

def self.reset
  @@callbacks = []
end