module KeyTree::Loader

Module to manage key tree loaders

Constants

BUILTIN_LOADERS

Attributes

fallback[W]
loaders[W]

Public Class Methods

[](type) click to toggle source
# File lib/key_tree/loader.rb, line 14
def [](type)
  type = type.to_sym if type.respond_to?(:to_sym)
  loaders[type] || @fallback
end
[]=(type, loader_class) click to toggle source
# File lib/key_tree/loader.rb, line 19
def []=(type, loader_class)
  type = type.to_sym if type.respond_to?(:to_sym)
  loaders[type] = loader_class
end

Private Class Methods

loaders() click to toggle source
# File lib/key_tree/loader.rb, line 29
def loaders
  @loaders ||= BUILTIN_LOADERS.each_with_object({}) do |pair, result|
    type, name = pair
    result[type] = const_get(name) if const_defined?(name)
  end
end