Sha256: 844e738ba984f4b1735ca5227d80bcea3298d935a97acb321d0b0898586e60b7

Contents?: true

Size: 601 Bytes

Versions: 14

Compression:

Stored size: 601 Bytes

Contents

# frozen_string_literal: true

module SteppedService
  class Errors < Hash
    def add(key, value, _opts = {})
      self[key] ||= []
      self[key] << value
      self[key].uniq!
    end

    def add_from_hash(errors_hash)
      errors_hash.each do |key, values|
        values.each { |value| add key, value }
      end
    end

    def full_messages
      f_msgs = []
      each_one { |field, message| f_msgs << "#{field}: #{message}" }
      f_msgs
    end

    def each_one
      each_pair do |field, messages|
        messages.each { |message| yield field, message }
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
czech_post_b2b_client-1.4.0 lib/stepped_service/errors.rb
czech_post_b2b_client-1.3.0 lib/stepped_service/errors.rb
czech_post_b2b_client-1.2.8 lib/stepped_service/errors.rb
czech_post_b2b_client-1.2.7 lib/stepped_service/errors.rb
czech_post_b2b_client-1.2.6 lib/stepped_service/errors.rb
czech_post_b2b_client-1.2.5 lib/stepped_service/errors.rb
czech_post_b2b_client-1.2.4 lib/stepped_service/errors.rb
czech_post_b2b_client-1.2.3 lib/stepped_service/errors.rb
czech_post_b2b_client-1.2.2 lib/stepped_service/errors.rb
czech_post_b2b_client-1.2.1 lib/stepped_service/errors.rb
czech_post_b2b_client-1.1.0 lib/stepped_service/errors.rb
czech_post_b2b_client-1.0.3 lib/stepped_service/errors.rb
czech_post_b2b_client-1.0.2 lib/stepped_service/errors.rb
czech_post_b2b_client-1.0.0 lib/stepped_service/errors.rb