Module: HTTPX::Chainable

Included in:
HTTPX, Session
Defined in:
lib/httpx/chainable.rb

Instance Method Summary collapse

Instance Method Details

#accept(type) ⇒ Object



23
24
25
# File 'lib/httpx/chainable.rb', line 23

def accept(type)
  headers("accept" => String(type))
end

#headers(headers) ⇒ Object



19
20
21
# File 'lib/httpx/chainable.rb', line 19

def headers(headers)
  branch(default_options.with_headers(headers))
end

#plugin(*plugins) ⇒ Object Also known as: plugins



31
32
33
34
35
36
# File 'lib/httpx/chainable.rb', line 31

def plugin(*plugins)
  klass = is_a?(Session) ? self.class : Session
  klass = Class.new(klass)
  klass.instance_variable_set(:@default_options, klass.default_options.merge(default_options))
  klass.plugins(plugins).new
end

#request(verb, uri, **options) ⇒ Object



11
12
13
# File 'lib/httpx/chainable.rb', line 11

def request(verb, uri, **options)
  branch(default_options).request(verb, uri, **options)
end

#timeout(**args) ⇒ Object



15
16
17
# File 'lib/httpx/chainable.rb', line 15

def timeout(**args)
  branch(default_options.with_timeout(args))
end

#with(options, &blk) ⇒ Object



39
40
41
# File 'lib/httpx/chainable.rb', line 39

def with(options, &blk)
  branch(default_options.merge(options), &blk)
end

#wrap(&blk) ⇒ Object



27
28
29
# File 'lib/httpx/chainable.rb', line 27

def wrap(&blk)
  branch(default_options).wrap(&blk)
end