class ActiveLoader::LoaderDispatcher

Attributes

content[R]
type[R]

Public Class Methods

new(content, type) click to toggle source
# File lib/active_loader/loader_dispatcher.rb, line 5
def initialize(content, type)
  @content = content
  @type = type
end

Public Instance Methods

call() click to toggle source
# 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

Private Instance Methods

load_json() click to toggle source
# File lib/active_loader/loader_dispatcher.rb, line 29
def load_json
  require "active_loader/json_loader"
  JsonLoader.new(content).call
end
load_yaml() click to toggle source
# File lib/active_loader/loader_dispatcher.rb, line 24
def load_yaml
  require "active_loader/yaml_loader"
  YamlLoader.new(content).call
end