Class: Humidifier::Reservoir::Config
- Inherits:
-
Object
- Object
- Humidifier::Reservoir::Config
- Defined in:
- lib/humidifier/reservoir/config.rb
Overview
A container class for the user-specified Reservoir configuration.
Instance Attribute Summary collapse
-
#mappings ⇒ Object
readonly
Returns the value of attribute mappings.
-
#stack_path ⇒ Object
Returns the value of attribute stack_path.
-
#stack_prefix ⇒ Object
Returns the value of attribute stack_prefix.
Instance Method Summary collapse
- #files_for(name) ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #map(type, opts = {}, &block) ⇒ Object
- #mapping_for(type) ⇒ Object
- #stacks ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config
8 9 10 |
# File 'lib/humidifier/reservoir/config.rb', line 8 def initialize @mappings = {} end |
Instance Attribute Details
#mappings ⇒ Object (readonly)
Returns the value of attribute mappings
5 6 7 |
# File 'lib/humidifier/reservoir/config.rb', line 5 def mappings @mappings end |
#stack_path ⇒ Object
Returns the value of attribute stack_path
5 6 7 |
# File 'lib/humidifier/reservoir/config.rb', line 5 def stack_path @stack_path end |
#stack_prefix ⇒ Object
Returns the value of attribute stack_prefix
6 7 8 |
# File 'lib/humidifier/reservoir/config.rb', line 6 def stack_prefix @stack_prefix end |
Instance Method Details
#files_for(name) ⇒ Object
12 13 14 15 |
# File 'lib/humidifier/reservoir/config.rb', line 12 def files_for(name) raise Error, 'You must configure a stack path' if stack_path.nil? Dir["#{stack_path}/#{name}/*.yml"] end |
#map(type, opts = {}, &block) ⇒ Object
17 18 19 |
# File 'lib/humidifier/reservoir/config.rb', line 17 def map(type, opts = {}, &block) mappings[type.to_sym] = Mapping.new(opts, &block) end |
#mapping_for(type) ⇒ Object
21 22 23 |
# File 'lib/humidifier/reservoir/config.rb', line 21 def mapping_for(type) mappings[type.to_sym] end |
#stacks ⇒ Object
32 33 34 35 36 |
# File 'lib/humidifier/reservoir/config.rb', line 32 def stacks Dir["#{stack_path}/*"].each_with_object([]) do |name, names| names << File.basename(name) if File.directory?(name) end end |