Sha256: 7d2efd42bba0fbfc7acf70d356a22149bc47e06378f4c1751cf9733434c58126

Contents?: true

Size: 825 Bytes

Versions: 13

Compression:

Stored size: 825 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

13 entries across 13 versions & 2 rubygems

Version Path
vanity-1.7.1 vendor/ruby/1.9.1/gems/webmock-1.6.4/lib/webmock/callback_registry.rb
webmock-1.6.4 lib/webmock/callback_registry.rb
webmock-1.6.2 lib/webmock/callback_registry.rb
webmock-1.6.1 lib/webmock/callback_registry.rb
webmock-1.6.0 lib/webmock/callback_registry.rb
webmock-1.5.0 lib/webmock/callback_registry.rb
webmock-1.4.0 lib/webmock/callback_registry.rb
webmock-1.3.5 lib/webmock/callback_registry.rb
webmock-1.3.4 lib/webmock/callback_registry.rb
webmock-1.3.3 lib/webmock/callback_registry.rb
webmock-1.3.2 lib/webmock/callback_registry.rb
webmock-1.3.1 lib/webmock/callback_registry.rb
webmock-1.3.0 lib/webmock/callback_registry.rb