lib/semantic_logger/formatters.rb in semantic_logger-4.2.0 vs lib/semantic_logger/formatters.rb in semantic_logger-4.2.1

- old
+ new

@@ -18,20 +18,18 @@ # - Hash ( Symbol => { options }) # - Instance of any of SemanticLogger::Formatters # - Proc # - Any object that responds to :call def self.factory(formatter) - case - when formatter.is_a?(Symbol) + if formatter.is_a?(Symbol) SemanticLogger::Utils.constantize_symbol(formatter, 'SemanticLogger::Formatters').new - when formatter.is_a?(Hash) && formatter.size > 0 + elsif formatter.is_a?(Hash) && formatter.size.positive? fmt, options = formatter.first SemanticLogger::Utils.constantize_symbol(fmt.to_sym, 'SemanticLogger::Formatters').new(options) - when formatter.respond_to?(:call) + elsif formatter.respond_to?(:call) formatter else raise(ArgumentError, "Unknown formatter: #{formatter.inspect}") end end - end end