Class: Ambience::Config
- Inherits:
-
Object
- Object
- Ambience::Config
- Defined in:
- lib/ambience/config.rb
Overview
Ambience::Config
App configuration feat. YAML and JVM properties. Lets you specify a default configuration in a YAML file and overwrite details via local settings and JVM properties for production.
Class Attribute Summary collapse
Instance Attribute Summary collapse
-
#base_config ⇒ Object
Returns the value of attribute base_config.
-
#env ⇒ Object
Returns the value of attribute env.
Instance Method Summary collapse
-
#initialize(base_config, env = nil) ⇒ Config
constructor
A new instance of Config.
-
#to_hash ⇒ Object
Returns the Ambience config as a Hash.
-
#to_mash ⇒ Object
Returns the Ambience config as a Hashie::Mash.
Constructor Details
#initialize(base_config, env = nil) ⇒ Config
Returns a new instance of Config.
30 31 32 33 |
# File 'lib/ambience/config.rb', line 30 def initialize(base_config, env = nil) self.base_config = base_config self.env = env end |
Class Attribute Details
.env_config ⇒ Object
22 23 24 |
# File 'lib/ambience/config.rb', line 22 def env_config @env_config ||= "AMBIENCE_CONFIG" end |
Instance Attribute Details
#base_config ⇒ Object
Returns the value of attribute base_config.
35 36 37 |
# File 'lib/ambience/config.rb', line 35 def base_config @base_config end |
#env ⇒ Object
Returns the value of attribute env.
35 36 37 |
# File 'lib/ambience/config.rb', line 35 def env @env end |
Instance Method Details
#to_hash ⇒ Object
Returns the Ambience config as a Hash.
38 39 40 41 42 |
# File 'lib/ambience/config.rb', line 38 def to_hash config = load_base_config config = config.deep_merge(load_env_config) config.deep_merge(load_jvm_config) end |
#to_mash ⇒ Object
Returns the Ambience config as a Hashie::Mash.
45 46 47 |
# File 'lib/ambience/config.rb', line 45 def to_mash Hashie::Mash.new to_hash end |