Class: UcbRails::Configuration::Configuration
- Inherits:
-
Object
- Object
- UcbRails::Configuration::Configuration
- Defined in:
- app/models/ucb_rails/configuration/configuration.rb
Overview
Manage configuration from file. Per environment or overall.
Constant Summary collapse
- FileNotFound =
Class.new(StandardError)
- KeyNotFound =
Class.new(StandardError)
Instance Attribute Summary collapse
-
#config_filename ⇒ Object
Returns the value of attribute config_filename.
-
#config_yaml ⇒ Object
Returns the value of attribute config_yaml.
Instance Method Summary collapse
-
#for(key) ⇒ Object
Return configuration value for key.
-
#for!(key) ⇒ Object
Return configuration value for key.
-
#initialize(filename = Rails.root.join('config/config.yml')) ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize(filename = Rails.root.join('config/config.yml')) ⇒ Configuration
Returns a new instance of Configuration.
31 32 33 34 |
# File 'app/models/ucb_rails/configuration/configuration.rb', line 31 def initialize(filename=Rails.root.join('config/config.yml')) self.config_filename = filename.to_s load_file end |
Instance Attribute Details
#config_filename ⇒ Object
Returns the value of attribute config_filename.
29 30 31 |
# File 'app/models/ucb_rails/configuration/configuration.rb', line 29 def config_filename @config_filename end |
#config_yaml ⇒ Object
Returns the value of attribute config_yaml.
29 30 31 |
# File 'app/models/ucb_rails/configuration/configuration.rb', line 29 def config_yaml @config_yaml end |
Instance Method Details
#for(key) ⇒ Object
Return configuration value for key.
38 39 40 |
# File 'app/models/ucb_rails/configuration/configuration.rb', line 38 def for(key) from_environment(key) || from_top_level(key) end |
#for!(key) ⇒ Object
Return configuration value for key.
44 45 46 |
# File 'app/models/ucb_rails/configuration/configuration.rb', line 44 def for!(key) self.for(key) or raise(KeyNotFound, key.inspect) end |