Module: HTTPX::Chainable
Instance Method Summary collapse
-
#accept(type) ⇒ Object
:nocov:.
- #headers(headers) ⇒ Object
- #plugin(pl, options = nil, &blk) ⇒ Object
-
#plugins(pls) ⇒ Object
deprecated :nocov:.
- #request(*args, **options) ⇒ Object
-
#timeout(**args) ⇒ Object
:nocov:.
-
#with(options, &blk) ⇒ Object
:nocov:.
- #wrap(&blk) ⇒ Object
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, **options) ⇒ Object (private)
90 91 92 93 94 95 96 97 98 |
# File 'lib/httpx/chainable.rb', line 90 def method_missing(meth, *args, **) return super unless meth =~ /\Awith_(.+)/ option = Regexp.last_match(1) return super unless option with(option.to_sym => (args.first || )) end |
Instance Method Details
#accept(type) ⇒ Object
:nocov:
42 43 44 |
# File 'lib/httpx/chainable.rb', line 42 def accept(type) with(headers: { "accept" => String(type) }) end |
#headers(headers) ⇒ Object
36 37 38 39 |
# File 'lib/httpx/chainable.rb', line 36 def headers(headers) warn ":#{__method__} is deprecated, use :with_headers instead" with(headers: headers) end |
#plugin(pl, options = nil, &blk) ⇒ Object
50 51 52 53 54 55 |
# File 'lib/httpx/chainable.rb', line 50 def plugin(pl, = nil, &blk) klass = is_a?(Session) ? self.class : Session klass = Class.new(klass) klass.instance_variable_set(:@default_options, klass..merge()) klass.plugin(pl, , &blk).new end |
#plugins(pls) ⇒ Object
deprecated :nocov:
59 60 61 62 63 64 65 |
# File 'lib/httpx/chainable.rb', line 59 def plugins(pls) warn ":#{__method__} is deprecated, use :plugin instead" klass = is_a?(Session) ? self.class : Session klass = Class.new(klass) klass.instance_variable_set(:@default_options, klass..merge()) klass.plugins(pls).new end |
#request(*args, **options) ⇒ Object
26 27 28 |
# File 'lib/httpx/chainable.rb', line 26 def request(*args, **) branch().request(*args, **) end |
#timeout(**args) ⇒ Object
:nocov:
31 32 33 34 |
# File 'lib/httpx/chainable.rb', line 31 def timeout(**args) warn ":#{__method__} is deprecated, use :with_timeout instead" with(timeout: args) end |
#with(options, &blk) ⇒ Object
:nocov:
68 69 70 |
# File 'lib/httpx/chainable.rb', line 68 def with(, &blk) branch(.merge(), &blk) end |
#wrap(&blk) ⇒ Object
46 47 48 |
# File 'lib/httpx/chainable.rb', line 46 def wrap(&blk) branch().wrap(&blk) end |