lib/config/validation/error.rb in config-1.7.2 vs lib/config/validation/error.rb in config-2.0.0

- old
+ new

@@ -1,23 +1,12 @@ module Config module Validation class Error < StandardError def self.format(v_res) - flatten_hash(v_res.messages).map do |field, msgs| - "#{' ' * 2}#{field}: #{msgs.join('; ')}" + v_res.errors.group_by(&:path).map do |path, messages| + "#{' ' * 2}#{path.join('.')}: #{messages.map(&:text).join('; ')}" end.join("\n") - end - - def self.flatten_hash(h, acc={}, pref=[]) - h.inject(acc) do |a, (k, v)| - if v.is_a?(Hash) - flatten_hash(v, acc, pref + [k]) - else - acc[(pref + [k]).join('.')] = v - acc - end - end end end end end