Class: PipeLineDealer::Client::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/pipe_line_dealer/client/connection.rb

Constant Summary collapse

DEFAULT_OPTIONS =
{
  http_debug: false
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, options) ⇒ Connection

Returns a new instance of Connection.



10
11
12
13
14
15
# File 'lib/pipe_line_dealer/client/connection.rb', line 10

def initialize(key, options)
  @key        = key
  @cache      = {}
  @options    = DEFAULT_OPTIONS.merge options
  @connection = build_connection
end

Instance Attribute Details

#cache(key, &block) ⇒ Object

Returns the value of attribute cache.



4
5
6
# File 'lib/pipe_line_dealer/client/connection.rb', line 4

def cache
  @cache
end

Instance Method Details

#build_connectionObject



17
18
19
20
21
22
23
# File 'lib/pipe_line_dealer/client/connection.rb', line 17

def build_connection
  Faraday.new(url: ENDPOINT) do |faraday|
    faraday.request  :url_encoded
    faraday.response :logger if @options[:http_debug]
    faraday.adapter  Faraday.default_adapter
  end
end