Class: RailsConfig::Sources::YAMLSource
- Inherits:
-
Object
- Object
- RailsConfig::Sources::YAMLSource
- Defined in:
- lib/rails_config/sources/yaml_source.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(path) ⇒ YAMLSource
constructor
A new instance of YAMLSource.
-
#load ⇒ Object
returns a config hash from the YML file.
Constructor Details
#initialize(path) ⇒ YAMLSource
Returns a new instance of YAMLSource.
10 11 12 |
# File 'lib/rails_config/sources/yaml_source.rb', line 10 def initialize(path) @path = path end |
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
8 9 10 |
# File 'lib/rails_config/sources/yaml_source.rb', line 8 def path @path end |
Instance Method Details
#load ⇒ Object
returns a config hash from the YML file
15 16 17 18 19 20 |
# File 'lib/rails_config/sources/yaml_source.rb', line 15 def load if @path and File.exists?(@path.to_s) result = YAML.load(ERB.new(IO.read(@path.to_s)).result) end result || {} end |