Module: Vectra::Config
Defined Under Namespace
Classes: RequiredOptionMissing
Instance Attribute Summary collapse
-
#endpoint ⇒ Object
Returns the value of attribute endpoint.
-
#password ⇒ Object
Returns the value of attribute password.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
-
#from_hash(options = {}) ⇒ Object
Configure vectra from a hash.
-
#load!(path) ⇒ Object
Load the settings from a compliant vectra.yml file.
Instance Attribute Details
#endpoint ⇒ Object
Returns the value of attribute endpoint.
6 7 8 |
# File 'lib/vectra/config.rb', line 6 def endpoint @endpoint end |
#password ⇒ Object
Returns the value of attribute password.
6 7 8 |
# File 'lib/vectra/config.rb', line 6 def password @password end |
#username ⇒ Object
Returns the value of attribute username.
6 7 8 |
# File 'lib/vectra/config.rb', line 6 def username @username end |
Instance Method Details
#from_hash(options = {}) ⇒ Object
Configure vectra from a hash. This is usually called after parsing a yaml config file such as vectra.yaml.
15 16 17 18 19 |
# File 'lib/vectra/config.rb', line 15 def from_hash( = {}) .each_pair do |name, value| send("#{name}=", value) if respond_to?("#{name}=") end end |
#load!(path) ⇒ Object
Load the settings from a compliant vectra.yml file. This can be used for easy setup with frameworks other than Rails.
28 29 30 31 32 33 |
# File 'lib/vectra/config.rb', line 28 def load!(path) settings = YAML.load(ERB.new(File.new(path).read).result) if settings.present? from_hash(settings) end end |