Module: Trell::Configurable

Included in:
Trell, Client
Defined in:
lib/trell/configurable.rb

Constant Summary collapse

OPTIONS_KEYS =
%i(
  login
  password
  application_key
  application_token
  api_endpoint
  web_endpoint
  user_agent
  media_type
  connection_options
  proxy
  middleware
)

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.keysObject



22
23
24
# File 'lib/trell/configurable.rb', line 22

def keys
  @keys ||= OPTIONS_KEYS
end

Instance Method Details

#api_endpointObject



31
32
33
# File 'lib/trell/configurable.rb', line 31

def api_endpoint
  File.join(@api_endpoint, '')
end

#configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



27
28
29
# File 'lib/trell/configurable.rb', line 27

def configure
  yield self
end

#reset!Object Also known as: setup



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/trell/configurable.rb', line 39

def reset!
  @login              = ENV['TRELL_LOGIN']
  @password           = ENV['TRELL_PASSWORD']
  @application_key    = ENV['TRELL_APPLICATION_TOKEN']
  @application_secret = ENV['TRELL_APPLICATION_SECRET']
  @api_endpoint       = ENV['TRELL_API_ENDPOINT'] || 'https://api.trello.com/1/'
  @web_endpoint       = ENV['TRELL_WEB_ENDPOINT'] || 'https://trello.com/'
  @user_agent         = "Trell Ruby Gem #{Trell::VERSION}"
  @media_type         = 'application/json'
  @connection_options = { headers: { accept: media_type, user_agent: user_agent } }
  @proxy              = ENV['TRELL_PROXY']
  @middleware         = Faraday::RackBuilder.new { |builder|
      builder.use Trell::Response::RaiseError
      builder.adapter Faraday.default_adapter
    }
  self
end

#web_endpointObject



35
36
37
# File 'lib/trell/configurable.rb', line 35

def web_endpoint
  File.join(@web_endpoint, '')
end