Sha256: 1b635b9fcfee9129fd75e0fe3c140f0f60aa64d5868c2f0dead0a9427f00bf4e

Contents?: true

Size: 1.49 KB

Versions: 40

Compression:

Stored size: 1.49 KB

Contents

module Manticore
  class Client
    module ProxiesInterface
      def respond_with(stubs)
        StubProxy.new(self, stubs)
      end

      # Causes the next request to be made asynchronously
      def async
        AsyncProxy.new(self)
      end

      alias_method :parallel, :async
      alias_method :batch, :async

      # Causes the next request to be made immediately in the background
      def background
        BackgroundProxy.new(self)
      end
    end

    class BaseProxy
      include ProxiesInterface

      def initialize(client)
        @client = client
      end
    end

    class AsyncProxy < BaseProxy
      %w(get put head post delete options patch).each do |func|
        define_method func do |url, options = {}, &block|
          @client.send(func, url, options.merge(async: true), &block)
        end
      end
    end

    class StubProxy < BaseProxy
      def initialize(client, stubs)
        super(client)
        @stubs = stubs
      end

      %w(get put head post delete options patch).each do |func|
        define_method func do |url, options = {}, &block|
          @client.stub(url, @stubs)
          @client.send(func, url, options, &block).complete { @client.unstub url }
        end
      end
    end

    class BackgroundProxy < BaseProxy
      %w(get put head post delete options patch).each do |func|
        define_method func do |url, options = {}, &block|
          @client.send(func, url, options.merge(async_background: true), &block)
        end
      end
    end
  end
end

Version data entries

40 entries across 40 versions & 5 rubygems

Version Path
manticore-0.9.1-java lib/manticore/client/proxies.rb
manticore-0.9.0-java lib/manticore/client/proxies.rb
manticore-0.8.0-java lib/manticore/client/proxies.rb
logstash-output-scalyr-0.2.1.beta vendor/bundle/jruby/2.5.0/gems/manticore-0.7.1-java/lib/manticore/client/proxies.rb
logstash-output-scalyr-0.2.0 vendor/bundle/jruby/2.5.0/gems/manticore-0.7.1-java/lib/manticore/client/proxies.rb
logstash-output-scalyr-0.2.0.beta vendor/bundle/jruby/2.5.0/gems/manticore-0.7.1-java/lib/manticore/client/proxies.rb
logstash-output-scalyr-0.1.26.beta vendor/bundle/jruby/2.5.0/gems/manticore-0.7.1-java/lib/manticore/client/proxies.rb
logstash-output-scalyr-0.1.25.beta vendor/bundle/jruby/2.5.0/gems/manticore-0.7.1-java/lib/manticore/client/proxies.rb
logstash-output-scalyr-0.1.24.beta vendor/bundle/jruby/2.5.0/gems/manticore-0.7.1-java/lib/manticore/client/proxies.rb
logstash-output-scalyr-0.1.23.beta vendor/bundle/jruby/2.5.0/gems/manticore-0.7.1-java/lib/manticore/client/proxies.rb
logstash-output-scalyr-0.1.22.beta vendor/bundle/jruby/2.5.0/gems/manticore-0.7.1-java/lib/manticore/client/proxies.rb
manticore-0.7.1-java lib/manticore/client/proxies.rb
logstash-output-scalyr-0.1.21.beta vendor/bundle/jruby/2.5.0/gems/manticore-0.6.4-java/lib/manticore/client/proxies.rb
logstash-output-scalyr-0.1.20.beta vendor/bundle/jruby/2.5.0/gems/manticore-0.6.4-java/lib/manticore/client/proxies.rb
logstash-output-scalyr-0.1.19.beta vendor/bundle/jruby/2.5.0/gems/manticore-0.6.4-java/lib/manticore/client/proxies.rb
logstash-output-scalyr-0.1.18.beta vendor/bundle/jruby/2.5.0/gems/manticore-0.6.4-java/lib/manticore/client/proxies.rb
logstash-output-scalyr-0.1.17.beta vendor/bundle/jruby/2.5.0/gems/manticore-0.6.4-java/lib/manticore/client/proxies.rb
logstash-output-scalyr-0.1.16.beta vendor/bundle/jruby/2.5.0/gems/manticore-0.6.4-java/lib/manticore/client/proxies.rb
logstash-output-scalyr-0.1.15.beta vendor/bundle/jruby/2.5.0/gems/manticore-0.6.4-java/lib/manticore/client/proxies.rb
logstash-output-scalyr-0.1.14.beta vendor/bundle/jruby/2.5.0/gems/manticore-0.6.4-java/lib/manticore/client/proxies.rb