Sha256: 6b28ad44d8fd2033709c34f579ae002e7b0fe245fafe3fc1f095326b542227ea
Contents?: true
Size: 776 Bytes
Versions: 2
Compression:
Stored size: 776 Bytes
Contents
# frozen_string_literal: true 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
key_tree-0.6.1 | lib/key_tree/loader.rb |
key_tree-0.6.0 | lib/key_tree/loader.rb |