Module: KeyTree::Loader
- Defined in:
- lib/key_tree/loader.rb
Overview
Module to manage key tree loaders
Constant Summary collapse
- BUILTIN_LOADERS =
{ json: 'JSON', yaml: 'YAML', yml: 'YAML' }.freeze
Class Method Summary collapse
Class Method Details
.[](type) ⇒ Object
9 10 11 12 |
# File 'lib/key_tree/loader.rb', line 9 def self.[](type) type = type.to_sym if type.respond_to?(:to_sym) loaders[type] end |
.[]=(type, loader_class) ⇒ Object
14 15 16 17 |
# File 'lib/key_tree/loader.rb', line 14 def self.[]=(type, loader_class) type = type.to_sym if type.respond_to?(:to_sym) loaders[type] = loader_class end |
.loaders ⇒ Object
21 22 23 24 25 26 |
# File 'lib/key_tree/loader.rb', line 21 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 |