Class: Envyable::Loader
- Inherits:
-
Object
- Object
- Envyable::Loader
- Defined in:
- lib/envyable/loader.rb
Overview
Internal: Loads yaml files into ENV (or a supplied hash).
Instance Attribute Summary collapse
-
#loadable ⇒ Object
readonly
Internal: Returns the Hash loadable of the loader.
-
#path ⇒ Object
readonly
Internal: Returns the String or Pathname path of the loader.
Instance Method Summary collapse
-
#initialize(path, loadable = ENV) ⇒ Loader
constructor
Internal: initalize a Loader.
-
#load(environment = 'development') ⇒ Object
Internal: perform the loading from the given environment.
Constructor Details
#initialize(path, loadable = ENV) ⇒ Loader
Internal: initalize a Loader
path - a Pathname or String that describes where the yaml file
resides.
loadable - a Hash or hashlike structure that the yaml file variables
should be loaded into (default: ENV).
16 17 18 19 |
# File 'lib/envyable/loader.rb', line 16 def initialize(path, loadable = ENV) @path = path @loadable = loadable end |
Instance Attribute Details
#loadable ⇒ Object (readonly)
Internal: Returns the Hash loadable of the loader
8 9 10 |
# File 'lib/envyable/loader.rb', line 8 def loadable @loadable end |
#path ⇒ Object (readonly)
Internal: Returns the String or Pathname path of the loader
5 6 7 |
# File 'lib/envyable/loader.rb', line 5 def path @path end |
Instance Method Details
#load(environment = 'development') ⇒ Object
Internal: perform the loading from the given environment
environment - a String describing the environment from which to load the
variables (default: development).
Examples
load(‘production’)
Returns nothing.
31 32 33 34 35 36 37 38 |
# File 'lib/envyable/loader.rb', line 31 def load(environment = 'development') if @yml ||= load_yml @yml.each { |key, value| set_value(key, value) } if @yml[environment] @yml[environment].each { |key, value| set_value(key, value) } end end end |