Module: KeyTree::Loader
- Defined in:
- lib/key_tree/loader.rb,
lib/key_tree/loader/nil.rb
Overview
Module to manage key tree loaders
Defined Under Namespace
Modules: Nil
Constant Summary collapse
- BUILTIN_LOADERS =
{ json: 'JSON', yaml: 'YAML', yml: 'YAML' }.freeze
Class Method Summary collapse
Class Method Details
.[](type) ⇒ Object
13 14 15 16 |
# File 'lib/key_tree/loader.rb', line 13 def self.[](type) type = type.to_sym if type.respond_to?(:to_sym) loaders[type] || @fallback end |
.[]=(type, loader_class) ⇒ Object
18 19 20 21 |
# File 'lib/key_tree/loader.rb', line 18 def self.[]=(type, loader_class) type = type.to_sym if type.respond_to?(:to_sym) loaders[type] = loader_class end |
.fallback(loader) ⇒ Object
23 24 25 |
# File 'lib/key_tree/loader.rb', line 23 def self.fallback(loader) @fallback = loader end |
.loaders ⇒ Object
29 30 31 32 33 34 |
# File 'lib/key_tree/loader.rb', line 29 def self.loaders @loaders ||= BUILTIN_LOADERS.each_with_object({}) do |pair, result| type, name = pair result[type] = const_get(name) if const_defined?(name) end end |