Sha256: eed2d6b5a68dc1e88e39d611f70ebb590264c38d8dba247f19485dd644453ca9

Contents?: true

Size: 846 Bytes

Versions: 13

Compression:

Stored size: 846 Bytes

Contents

# frozen_string_literal: true

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

13 entries across 13 versions & 4 rubygems

Version Path
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/webmock-3.23.1/lib/webmock/callback_registry.rb
webmock-3.24.0 lib/webmock/callback_registry.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/webmock-3.23.1/lib/webmock/callback_registry.rb
webmock-3.23.0 lib/webmock/callback_registry.rb
webmock-3.22.0 lib/webmock/callback_registry.rb
webmock-3.21.2 lib/webmock/callback_registry.rb
webmock-3.21.1 lib/webmock/callback_registry.rb
webmock-3.21.0 lib/webmock/callback_registry.rb
webmock-3.20.0 lib/webmock/callback_registry.rb
honeybadger-5.4.0 vendor/bundle/ruby/3.2.0/gems/webmock-3.19.1/lib/webmock/callback_registry.rb
honeybadger-5.3.0 vendor/bundle/ruby/3.2.0/gems/webmock-3.19.1/lib/webmock/callback_registry.rb
webmock-3.19.1 lib/webmock/callback_registry.rb
webmock-3.19.0 lib/webmock/callback_registry.rb