Class: Ambience::Config

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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_configObject



22
23
24
# File 'lib/ambience/config.rb', line 22

def env_config
  @env_config ||= "AMBIENCE_CONFIG"
end

Instance Attribute Details

#base_configObject

Returns the value of attribute base_config.



35
36
37
# File 'lib/ambience/config.rb', line 35

def base_config
  @base_config
end

#envObject

Returns the value of attribute env.



35
36
37
# File 'lib/ambience/config.rb', line 35

def env
  @env
end

Instance Method Details

#to_hashObject

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_mashObject

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