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
11 12 13 14 |
# File 'lib/key_tree/loader.rb', line 11 def self.[](type) type = type.to_sym if type.respond_to?(:to_sym) loaders[type] || @fallback end |
.[]=(type, loader_class) ⇒ Object
16 17 18 19 |
# File 'lib/key_tree/loader.rb', line 16 def self.[]=(type, loader_class) type = type.to_sym if type.respond_to?(:to_sym) loaders[type] = loader_class end |
.fallback(loader) ⇒ Object
21 22 23 |
# File 'lib/key_tree/loader.rb', line 21 def self.fallback(loader) @fallback = loader end |
.loaders ⇒ Object
27 28 29 30 31 32 |
# File 'lib/key_tree/loader.rb', line 27 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 |