Class: CFC::Config

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/cfc/config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#api_emailObject

Returns the value of attribute api_email.



7
8
9
# File 'lib/cfc/config.rb', line 7

def api_email
  @api_email
end

#api_keyObject

Returns the value of attribute api_key.



7
8
9
# File 'lib/cfc/config.rb', line 7

def api_key
  @api_key
end

#tokenObject

Returns the value of attribute token.



7
8
9
# File 'lib/cfc/config.rb', line 7

def token
  @token
end

Class Method Details

.configure {|CFC::Config.instance| ... } ⇒ Object

Yields:



9
10
11
12
13
14
15
16
17
# File 'lib/cfc/config.rb', line 9

def self.configure
  yield CFC::Config.instance
  if [instance.token, instance.api_key, instance.api_email].all?(&:nil?)
    raise CFC::Errors::ConfigurationError, 'Either `token` or BOTH of `api_key`, `api_email` must be set on call ' \
                                           "to `configure'."
  elsif instance.token.nil? && [instance.api_key, instance.api_email].any?(&:nil?)
    raise CFC::Errors::ConfigurationError, 'Both `api_key` AND `api_email` must be set when not using token auth.'
  end
end