Sha256: 2dbb738c198b9a2b5eb2acb7b096910447cbec2ca13ecf8bed31a0d95c62a150
Contents?: true
Size: 745 Bytes
Versions: 4
Compression:
Stored size: 745 Bytes
Contents
require 'key_tree/loader/nil' module KeyTree # Module to manage key tree loaders module Loader BUILTIN_LOADERS = { json: 'JSON', yaml: 'YAML', yml: 'YAML' }.freeze def self.[](type) type = type.to_sym if type.respond_to?(:to_sym) loaders[type] || @fallback end def self.[]=(type, loader_class) type = type.to_sym if type.respond_to?(:to_sym) loaders[type] = loader_class end def self.fallback(loader) @fallback = loader end private_class_method 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 end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
key_tree-0.5.3 | lib/key_tree/loader.rb |
key_tree-0.5.2 | lib/key_tree/loader.rb |
key_tree-0.5.1 | lib/key_tree/loader.rb |
key_tree-0.5.0 | lib/key_tree/loader.rb |