Sha256: f0af934207a48ca06e46d7227c0ef6c8b760b05ab320ba271c7aa6c85c6b1995

Contents?: true

Size: 526 Bytes

Versions: 7

Compression:

Stored size: 526 Bytes

Contents

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('; ')}"
        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

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
config-1.7.1 lib/config/validation/error.rb
ef-config-1.4.1 lib/config/validation/error.rb
config-1.7.0 lib/config/validation/error.rb
config-1.6.1 lib/config/validation/error.rb
config-1.6.0 lib/config/validation/error.rb
config-1.5.1 lib/config/validation/error.rb
config-1.5.0 lib/config/validation/error.rb