Class: Boxxspring::Worker::Configuration
- Includes:
- Singleton
- Defined in:
- lib/boxxspring/worker/configuration.rb
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Abstract
#include?, #initialize, #method_missing, #to_hash
Constructor Details
This class inherits a constructor from Boxxspring::Abstract
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Boxxspring::Abstract
Class Method Details
.reloadable? ⇒ Boolean
11 12 13 |
# File 'lib/boxxspring/worker/configuration.rb', line 11 def self.reloadable? false end |
Instance Method Details
#from_hash(configuration) ⇒ Object
15 16 17 18 19 |
# File 'lib/boxxspring/worker/configuration.rb', line 15 def from_hash( configuration ) configuration.each_pair do | name, value | self.send( "@#{name}", value ) end end |
#get_token(options = {}) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/boxxspring/worker/configuration.rb', line 21 def get_token( = {} ) token_details = Unimatrix::Authorization::ClientCredentialsGrant.new( client_id: ENV[ 'KEYMAKER_CLIENT' ], client_secret: ENV[ 'KEYMAKER_SECRET' ] ).request_token( ) if token_details.include?( 'error' ) puts "ERROR: #{ token_details }" end if token_details.is_a?( Hash ) token_details.symbolize_keys! token_details.update( expires_in: Time.now + token_details[ :expires_in ] ) if token_details[ :expires_in ] api_credentials.access_token = token_details[ :access_token ] api_credentials.token_expiry = token_details[ :expires_in ] result = api_credentials else result = token_details end result end |