Class: Pears::Provider::RailsConfig
- Defined in:
- lib/pears/provider/rails_config.rb
Overview
Used for loading simple YAML file locally.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(*path_parts, on_failure: :raise) ⇒ RailsConfig
constructor
A new instance of RailsConfig.
Methods inherited from Base
Constructor Details
#initialize(*path_parts, on_failure: :raise) ⇒ RailsConfig
Returns a new instance of RailsConfig.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/pears/provider/rails_config.rb', line 8 def initialize(*path_parts, on_failure: :raise) file = path_parts.pop file_path = Rails.root.join('config', *path_parts, "#{file}.yml") yaml_data = File.read(file_path) @data = parse_yaml(yaml_data) rescue Errno::ENOENT, Pears::InvalidProviderData => error if on_failure == :null @data = {} else raise error end end |