Module: Arrolio::Style::Loader

Defined in:
lib/arrolio/style/loader.rb

Class Method Summary collapse

Class Method Details

.load(source) ⇒ Object



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

def load(source)
  Registry.new(load_hash(source) || {})
end

.load_hash(source) ⇒ Object



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

def load_hash(source)
  case source
  when Hash then source
  when String then ::YAML.safe_load(source, aliases: true) || {}
  when IO, StringIO then ::YAML.safe_load(source.read, aliases: true) || {}
  else
    raise ArgumentError, 'Loader.load needs a Hash, String, or IO'
  end
end