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