Sha256: 2cb04179f0567b53420099c48cfe883b5303bfbf5beb5c05eab93cd3c6f0476e
Contents?: true
Size: 1.16 KB
Versions: 2
Compression:
Stored size: 1.16 KB
Contents
# frozen_string_literal: true module RDStation class Error class Format FLAT_HASH = 'FLAT_HASH' HASH_OF_ARRAYS = 'HASH_OF_ARRAYS' ARRAY_OF_HASHES = 'ARRAY_OF_HASHES' HASH_OF_MULTIPLE_TYPES = 'HASH_OF_MULTIPLE_TYPES' HASH_OF_HASHES = 'HASH_OF_HASHES' def initialize(errors) @errors = errors end def format return FLAT_HASH if flat_hash? return HASH_OF_ARRAYS if hash_of_arrays? return HASH_OF_HASHES if hash_of_hashes? return HASH_OF_MULTIPLE_TYPES if hash_of_multiple_types? ARRAY_OF_HASHES end private def flat_hash? return unless @errors.is_a?(Hash) @errors.key?('error_type') end def hash_of_arrays? @errors.is_a?(Hash) && @errors.values.all? { |error| error.is_a? Array } end def hash_of_hashes? @errors.is_a?(Hash) && @errors.values.all? { |error| error.is_a? Hash } end def hash_of_multiple_types? @errors.is_a?(Hash) && @errors.values.any? { |error| error.is_a? Hash } && @errors.values.any? { |error| error.is_a? Array } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rdstation-ruby-client-2.3.1 | lib/rdstation/error/format.rb |
rdstation-ruby-client-2.3.0 | lib/rdstation/error/format.rb |