Module: DataAccessible::DataLoader
- Defined in:
- lib/data_accessible/data_loader.rb
Class Method Summary collapse
Class Method Details
.load_from_file(file) ⇒ Object
16 17 18 19 20 |
# File 'lib/data_accessible/data_loader.rb', line 16 def load_from_file(file) contents = File.read(file) evaluated_contents = process_erb(contents) YAML.load(evaluated_contents) || {} end |
.load_source(data_source) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/data_accessible/data_loader.rb', line 22 def load_source(data_source) case data_source when Hash data_source when String load_from_file(data_source) when Symbol load_from_file("#{DataAccessible.data_path}/#{data_source}.yml") else raise("Invalid data source provided: #{data_source}") end end |
.process_erb(text) ⇒ Object
12 13 14 |
# File 'lib/data_accessible/data_loader.rb', line 12 def process_erb(text) ERB.new(text).result end |