Class: Truesenses::Config
- Inherits:
-
Object
- Object
- Truesenses::Config
- Defined in:
- lib/truesenses/config.rb
Instance Attribute Summary collapse
-
#deliver ⇒ Object
readonly
Returns the value of attribute deliver.
-
#origin ⇒ Object
readonly
Returns the value of attribute origin.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#protocol ⇒ Object
readonly
Returns the value of attribute protocol.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Class Method Summary collapse
-
.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)).
Instance Method Summary collapse
-
#initialize(options) ⇒ Config
constructor
: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.
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() = .stringify_keys @password = ['password'] @username = ['username'] @protocol = ['protocol'] || :http @origin = ['origin'] @deliver = .has_key?('deliver') ? ['deliver'] : true verify! end |
Instance Attribute Details
#deliver ⇒ Object (readonly)
Returns the value of attribute deliver.
3 4 5 |
# File 'lib/truesenses/config.rb', line 3 def deliver @deliver end |
#origin ⇒ Object (readonly)
Returns the value of attribute origin.
3 4 5 |
# File 'lib/truesenses/config.rb', line 3 def origin @origin end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
3 4 5 |
# File 'lib/truesenses/config.rb', line 3 def password @password end |
#protocol ⇒ Object (readonly)
Returns the value of attribute protocol.
3 4 5 |
# File 'lib/truesenses/config.rb', line 3 def protocol @protocol end |
#username ⇒ Object (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 |