Class: ConfigSpartan
- Inherits:
-
Object
- Object
- ConfigSpartan
- Defined in:
- lib/config_spartan.rb,
lib/config_spartan/version.rb
Constant Summary collapse
- VERSION =
"1.0.1"
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Class Method Summary collapse
Instance Method Summary collapse
- #file(path) ⇒ Object
-
#initialize ⇒ ConfigSpartan
constructor
A new instance of ConfigSpartan.
Constructor Details
#initialize ⇒ ConfigSpartan
Returns a new instance of ConfigSpartan.
15 16 17 |
# File 'lib/config_spartan.rb', line 15 def initialize @config = Hashie::Mash.new end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
9 10 11 |
# File 'lib/config_spartan.rb', line 9 def config @config end |
Class Method Details
.create(&block) ⇒ Object
11 12 13 |
# File 'lib/config_spartan.rb', line 11 def self.create(&block) new.tap{ |spartan| spartan.instance_eval(&block) }.config end |
Instance Method Details
#file(path) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/config_spartan.rb', line 19 def file(path) data = File.read(path) yaml = ERB.new(data).result hash = YAML.load(yaml) mash = Hashie::Mash.new(hash) @config.deep_merge!(mash) end |