Sha256: c7662fbe06dd8ff27ca9a262821399ca172aa8a522e8c6be4281b4de675339df

Contents?: true

Size: 815 Bytes

Versions: 105

Compression:

Stored size: 815 Bytes

Contents

module WebMock
  class CallbackRegistry
    @@callbacks = []

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

    def self.callbacks
      @@callbacks
    end

    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

    def self.reset
      @@callbacks = []
    end

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

  end
end

Version data entries

105 entries across 99 versions & 8 rubygems

Version Path
vagrant-unbundled-2.2.6.0 vendor/bundle/ruby/2.6.0/gems/webmock-2.3.2/lib/webmock/callback_registry.rb
webmock-3.7.6 lib/webmock/callback_registry.rb
webmock-3.7.5 lib/webmock/callback_registry.rb
webmock-3.7.4 lib/webmock/callback_registry.rb
webmock-3.7.3 lib/webmock/callback_registry.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.5.0/gems/webmock-2.3.2/lib/webmock/callback_registry.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.6.0/gems/webmock-2.3.2/lib/webmock/callback_registry.rb
webmock-3.7.2 lib/webmock/callback_registry.rb
webmock-3.7.1 lib/webmock/callback_registry.rb
webmock-3.7.0 lib/webmock/callback_registry.rb
webmock-3.6.2 lib/webmock/callback_registry.rb
webmock-3.6.0 lib/webmock/callback_registry.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.5.0/gems/webmock-2.3.2/lib/webmock/callback_registry.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.6.0/gems/webmock-2.3.2/lib/webmock/callback_registry.rb
vagrant-unbundled-2.2.3.0 vendor/bundle/ruby/2.5.0/gems/webmock-2.3.2/lib/webmock/callback_registry.rb
webmock-3.5.1 lib/webmock/callback_registry.rb
webmock-3.5.0 lib/webmock/callback_registry.rb
vagrant-unbundled-2.2.2.0 vendor/bundle/ruby/2.5.0/gems/webmock-2.3.2/lib/webmock/callback_registry.rb
vagrant-unbundled-2.2.0.0 vendor/bundle/ruby/2.5.0/gems/webmock-2.3.2/lib/webmock/callback_registry.rb
vagrant-unbundled-2.1.4.0 vendor/bundle/ruby/2.5.0/gems/webmock-2.3.2/lib/webmock/callback_registry.rb