module HTTPX::Chainable

  1. lib/httpx/chainable.rb

Session mixin, implements most of the APIs that the users call. delegates to a default session when extended.

Methods

Public Instance

  1. accept
  2. plugin
  3. request
  4. with
  5. wrap

Public Instance methods

accept(type)
[show source]
   # File lib/httpx/chainable.rb
20 def accept(type)
21   with(headers: { "accept" => String(type) })
22 end
plugin(pl, options = nil, &blk)

returns a new instance loaded with the pl plugin and options.

[show source]
   # File lib/httpx/chainable.rb
30 def plugin(pl, options = nil, &blk)
31   klass = is_a?(S) ? self.class : Session
32   klass = Class.new(klass)
33   klass.instance_variable_set(:@default_options, klass.default_options.merge(default_options))
34   klass.plugin(pl, options, &blk).new
35 end
request(*args, **options)

delegates to the default session (see HTTPX::Session#request).

[show source]
   # File lib/httpx/chainable.rb
16 def request(*args, **options)
17   branch(default_options).request(*args, **options)
18 end
with(options, &blk)

returns a new instance loaded with options.

[show source]
   # File lib/httpx/chainable.rb
38 def with(options, &blk)
39   branch(default_options.merge(options), &blk)
40 end
wrap(&blk)

delegates to the default session (see HTTPX::Session#wrap).

[show source]
   # File lib/httpx/chainable.rb
25 def wrap(&blk)
26   branch(default_options).wrap(&blk)
27 end