Module: Cogwheels::Loader

Defined in:
lib/cogwheels/loader.rb

Overview

This module helps in loading YAML configurations from different source types

Class Method Summary collapse

Class Method Details

.from_file(file) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/cogwheels/loader.rb', line 14

def from_file(file)
  hash = {}
  if File.exist?(file)
    yaml = IO.read(file)
    hash = safe_load(yaml, File.path(file))
  end
  hash
end

.load(src, mutable = true) ⇒ Object



10
11
12
# File 'lib/cogwheels/loader.rb', line 10

def load(src, mutable = true)
  return Configuration.new(from_file(src), mutable) if File.file?(src)
end