Module: Tinybucket::Connection

Included in:
Api::BaseApi
Defined in:
lib/tinybucket/connection.rb

Constant Summary collapse

DEFAULT_USER_AGENT =
'Tinybucket Ruby Bitbucket REST client'.freeze

Instance Method Summary collapse

Instance Method Details

#caching?Boolean

Returns:

  • (Boolean)

11
12
13
# File 'lib/tinybucket/connection.rb', line 11

def caching?
  !@connection.nil?
end

#clear_cacheObject


7
8
9
# File 'lib/tinybucket/connection.rb', line 7

def clear_cache
  @connection = nil
end

#connection(parser = nil, options = {}) ⇒ Object


15
16
17
18
19
20
21
22
23
# File 'lib/tinybucket/connection.rb', line 15

def connection(parser = nil, options = {})
  conn_options = default_options(options)
  clear_cache

  # TODO: cache connection for each (options, parser) pairs.
  Faraday.new(
    conn_options.merge(builder: stack(parser, options))
  )
end