lib/qonfig/loaders.rb in qonfig-0.14.0 vs lib/qonfig/loaders.rb in qonfig-0.15.0

- old
+ new

@@ -4,6 +4,28 @@ # @since 0.2.0 module Qonfig::Loaders require_relative 'loaders/basic' require_relative 'loaders/json' require_relative 'loaders/yaml' + require_relative 'loaders/end_data' + + class << self + # @param format [String, Symbol] + # @return [Module] + # + # @raise [Qonfig::UnsupportedLoaderFormatError] + # + # @api private + # @since 0.15.0 + def resolve(format) + case format.to_s + when 'yaml', 'yml' + Qonfig::Loaders::YAML + when 'json' + Qonfig::Loaders::JSON + else + raise(Qonfig::UnsupportedLoaderFormatError, "<#{format}> format is not supported.") + end + end + alias_method :[], :resolve + end end