Class: Truesenses::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/truesenses/config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Config

:username :password :protocol :http or :https, defaults to :http :origin default origin ID of text message :deliver true|false, false turns on the TEST mode of truesenses API



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

def initialize(options)
  options = options.stringify_keys
  @password = options['password']
  @username = options['username']
  @protocol = options['protocol'] || :http
  @origin = options['origin']
  @deliver = options.has_key?('deliver') ? options['deliver'] : true
  verify!
end

Instance Attribute Details

#deliverObject (readonly)

Returns the value of attribute deliver.



3
4
5
# File 'lib/truesenses/config.rb', line 3

def deliver
  @deliver
end

#originObject (readonly)

Returns the value of attribute origin.



3
4
5
# File 'lib/truesenses/config.rb', line 3

def origin
  @origin
end

#passwordObject (readonly)

Returns the value of attribute password.



3
4
5
# File 'lib/truesenses/config.rb', line 3

def password
  @password
end

#protocolObject (readonly)

Returns the value of attribute protocol.



3
4
5
# File 'lib/truesenses/config.rb', line 3

def protocol
  @protocol
end

#usernameObject (readonly)

Returns the value of attribute username.



3
4
5
# File 'lib/truesenses/config.rb', line 3

def username
  @username
end

Class Method Details

.load(filename, root = nil) ⇒ Object

Load config from a YAML file if root is specified, then this root key is used (useful when you store different configurations in one YAML file: Config.load(‘somefile.yml’, RAILS_ENV))



23
24
25
26
# File 'lib/truesenses/config.rb', line 23

def self.load(filename, root = nil)
  data = YAML.load_file(filename)
  Config.new(root ? data[root] : data)
end