Class: LoogiHttp::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/loogi_http/builder.rb

Overview

Conveniently configure ‘Faraday` stacks.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.jsonLoogiHttp::Connection

Configure a JSON stack.



10
11
12
# File 'lib/loogi_http/builder.rb', line 10

def self.json
  new.build(&:json)
end

Instance Method Details

#build {|config| ... } ⇒ LoogiHttp::Connection

Customize a stack with a configuration block.

Example:

LoogiHttp::Builder.new.configure do |config|

config.json

end

Yields:

  • (config)

    Customize the stack within this block

Yield Parameters:

Returns:



25
26
27
28
29
30
31
# File 'lib/loogi_http/builder.rb', line 25

def build(&block)
  LoogiHttp::Connection.new(
    faraday_connection do |conn|
      LoogiHttp::Configuration.new(conn).configure(&block)
    end
  )
end