Class: PeanutLabs::Credentials
- Inherits:
-
Object
- Object
- PeanutLabs::Credentials
- Defined in:
- lib/peanut_labs/credentials.rb
Constant Summary collapse
- DEFAULT_PARAMS =
{ app_id: nil, app_key: nil }.freeze
Instance Attribute Summary collapse
-
#id ⇒ Object
accepts params for app credentials or tries to retrieve them from ENV variables.
-
#key ⇒ Object
accepts params for app credentials or tries to retrieve them from ENV variables.
Instance Method Summary collapse
-
#initialize(params = nil) ⇒ Credentials
constructor
A new instance of Credentials.
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
#id ⇒ Object
17 18 19 |
# File 'lib/peanut_labs/credentials.rb', line 17 def id @id end |
#key ⇒ Object
17 18 19 |
# File 'lib/peanut_labs/credentials.rb', line 17 def key @key end |