Class: ActiveLoader::LoaderDispatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/active_loader/loader_dispatcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(content, type) ⇒ LoaderDispatcher

Returns a new instance of LoaderDispatcher.



5
6
7
8
# File 'lib/active_loader/loader_dispatcher.rb', line 5

def initialize(content, type)
  @content = content
  @type = type
end

Instance Method Details

#callObject



10
11
12
13
14
15
16
17
18
# File 'lib/active_loader/loader_dispatcher.rb', line 10

def call
  if type == :json
    load_json
  elsif [:yaml, :yml].include?(type)
    load_yaml
  else
    raise UnknownTypeError, "Unknown type of file: #{type}."
  end
end