Class: PawClient::Configuration

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Configuration

Returns a new instance of Configuration.



27
28
29
30
31
32
33
34
# File 'lib/paw_client/configuration.rb', line 27

def initialize(attrs={})
  self.base_url                 = attrs.fetch(:base_url, nil)
  self.uuid                     = attrs.fetch(:uuid, nil)
  self.token                 = attrs.fetch(:token, nil)
  self.user_token                 = attrs.fetch(:user_token, nil)
  self.logger                   = attrs.fetch(:logger, nil)
  self.test_mode                = attrs.fetch(:test_mode, false)
end

Instance Attribute Details

#base_urlObject

Returns the value of attribute base_url.



4
5
6
# File 'lib/paw_client/configuration.rb', line 4

def base_url
  @base_url
end

#loggerObject

Returns the value of attribute logger.



9
10
11
# File 'lib/paw_client/configuration.rb', line 9

def logger
  @logger
end

#test_modeObject

Returns the value of attribute test_mode.



8
9
10
# File 'lib/paw_client/configuration.rb', line 8

def test_mode
  @test_mode
end

#tokenObject

Returns the value of attribute token.



6
7
8
# File 'lib/paw_client/configuration.rb', line 6

def token
  @token
end

#user_tokenObject

Returns the value of attribute user_token.



7
8
9
# File 'lib/paw_client/configuration.rb', line 7

def user_token
  @user_token
end

#uuidObject

Returns the value of attribute uuid.



5
6
7
# File 'lib/paw_client/configuration.rb', line 5

def uuid
  @uuid
end

Class Method Details

.from_yaml(path, env = nil) ⇒ Object



36
37
38
39
40
41
# File 'lib/paw_client/configuration.rb', line 36

def self.from_yaml(path, env=nil)
  attrs = YAML.load_file(path)
  attrs = attrs[env] if env
  sym_attrs=attrs.each_with_object({}) {|(k, v), memo| memo[k.to_sym] = v}
  self.new(sym_attrs)
end