Class: PeanutLabs::Credentials

Inherits:
Object
  • Object
show all
Defined in:
lib/peanut_labs/credentials.rb

Constant Summary collapse

DEFAULT_PARAMS =
{ app_id: nil, app_key: nil }.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = nil) ⇒ Credentials

Returns a new instance of Credentials.



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/peanut_labs/credentials.rb', line 19

def initialize(params=nil)
  params ||= DEFAULT_PARAMS

  @id = params[:app_id] || ENV['PEANUTLABS_ID']
  @key = params[:app_key] || ENV['PEANUTLABS_KEY']

  if id.nil? || key.nil? || id.empty? || key.empty?
    raise PeanutLabs::CredentialsMissingError
  end

end

Instance Attribute Details

#idObject

accepts params for app credentials or tries to retrieve them from ENV variables

params = application id provided by peanut labs params = application key provided by peanut labs

or provide via ENV variable

ENV ENV



17
18
19
# File 'lib/peanut_labs/credentials.rb', line 17

def id
  @id
end

#keyObject

accepts params for app credentials or tries to retrieve them from ENV variables

params = application id provided by peanut labs params = application key provided by peanut labs

or provide via ENV variable

ENV ENV



17
18
19
# File 'lib/peanut_labs/credentials.rb', line 17

def key
  @key
end