Class: BlueprintConfig::Configuration
- Inherits:
-
Object
- Object
- BlueprintConfig::Configuration
- Includes:
- Singleton
- Defined in:
- lib/blueprint_config/configuration.rb
Instance Attribute Summary collapse
-
#backends ⇒ Object
Returns the value of attribute backends.
-
#config ⇒ Object
Returns the value of attribute config.
Instance Method Summary collapse
Instance Attribute Details
permalink #backends ⇒ Object
Returns the value of attribute backends.
11 12 13 |
# File 'lib/blueprint_config/configuration.rb', line 11 def backends @backends end |
permalink #config ⇒ Object
Returns the value of attribute config.
11 12 13 |
# File 'lib/blueprint_config/configuration.rb', line 11 def config @config end |
Instance Method Details
permalink #init(&block) ⇒ Object
[View source]
24 25 26 27 28 29 |
# File 'lib/blueprint_config/configuration.rb', line 24 def init(&block) backends = BackendCollection.new block.call(backends) @backends = backends reload! end |
permalink #process_erb(object) ⇒ Object
[View source]
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/blueprint_config/configuration.rb', line 47 def process_erb(object) case object when String if object.start_with?('<%=') && object.end_with?('%>') ERB.new(object).result(binding) else object end when OptionsArray object.each_with_index { |o, index| object[index] = process_erb(o) } when OptionsHash object.each { |k, v| object[k] = process_erb(v) } else object end end |
permalink #refine(&block) ⇒ Object
[View source]
31 32 33 34 35 36 |
# File 'lib/blueprint_config/configuration.rb', line 31 def refine(&block) backends = @backends block.call(backends) @backends = backends reload! end |
permalink #reload! ⇒ Object
[View source]
38 39 40 41 42 43 44 45 |
# File 'lib/blueprint_config/configuration.rb', line 38 def reload! new_config = @backends.each_with_object(OptionsHash.new) do |backend, config| config.deep_merge! OptionsHash.new(backend.load_keys, source: backend.source) end @config = new_config @config = process_erb(new_config) end |