Class: Tacokit::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/tacokit/configuration.rb

Constant Summary collapse

API_URL =
"https://api.trello.com".freeze
WEB_URL =
"https://trello.com".freeze
API_VERSION =
"1".freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Configuration

Returns a new instance of Configuration.



22
23
24
# File 'lib/tacokit/configuration.rb', line 22

def initialize(opts = {})
  self.options = defaults.merge(opts)
end

Class Method Details

.keysObject



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/tacokit/configuration.rb', line 8

def self.keys
  [
    :app_key,
    :app_secret,
    :app_token,
    :oauth_token,
    :oauth_secret,
    :api_endpoint,
    :web_endpoint
  ]
end

Instance Method Details

#app_authenticated?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/tacokit/configuration.rb', line 38

def app_authenticated?
  app_key && app_token
end

#app_credentialsObject



42
43
44
# File 'lib/tacokit/configuration.rb', line 42

def app_credentials
  { key: app_key, token: app_token }.delete_if { |k, v| v.nil? }
end

#options=(opts) ⇒ Object



26
27
28
# File 'lib/tacokit/configuration.rb', line 26

def options=(opts)
  opts.each { |key, value| instance_variable_set("@#{key}", value) }
end

#user_authenticated?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/tacokit/configuration.rb', line 30

def user_authenticated?
  app_key && oauth_token
end

#user_credentialsObject



34
35
36
# File 'lib/tacokit/configuration.rb', line 34

def user_credentials
  { consumer_key: app_key, token: oauth_token }.delete_if { |k, v| v.nil? }
end