Class: BarkingIguana::Compound::Environment
- Inherits:
-
Object
- Object
- BarkingIguana::Compound::Environment
- Includes:
- Logging::Helper
- Defined in:
- lib/barking_iguana/compound/environment.rb
Instance Method Summary collapse
-
#initialize(file) ⇒ Environment
constructor
A new instance of Environment.
- #merge(override) ⇒ Object
- #present? ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(file) ⇒ Environment
Returns a new instance of Environment.
12 13 14 15 |
# File 'lib/barking_iguana/compound/environment.rb', line 12 def initialize file self.file = file self.overrides = [] end |
Instance Method Details
#merge(override) ⇒ Object
17 18 19 20 21 |
# File 'lib/barking_iguana/compound/environment.rb', line 17 def merge override logger.debug { "ENV registering override: #{override.inspect}" } overrides << override self end |
#present? ⇒ Boolean
35 36 37 |
# File 'lib/barking_iguana/compound/environment.rb', line 35 def present? File.exists? file end |
#to_h ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/barking_iguana/compound/environment.rb', line 23 def to_h logger.debug { "ENV evaluating #{file.inspect} (present: #{present?})" } h = my_values logger.debug { "ENV from #{file.inspect}: #{h.inspect}" } overrides.each do |override| h.merge! override.to_h logger.debug { "ENV after merging #{override.inspect}: #{h.inspect}" } end logger.debug { "ENV returned from #{file.inspect}: #{h.inspect}" } h end |