Class: ConvenientService::Utils::Hash::TripleEqualityCompare

Inherits:
Support::Command show all
Defined in:
lib/convenient_service/utils/hash/triple_equality_compare.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Support::Command

[], call

Constructor Details

#initialize(hash, other_hash) ⇒ void

Parameters:



32
33
34
35
# File 'lib/convenient_service/utils/hash/triple_equality_compare.rb', line 32

def initialize(hash, other_hash)
  @hash = hash
  @other_hash = other_hash
end

Instance Attribute Details

#hashObject (readonly)

Returns the value of attribute hash.



19
20
21
# File 'lib/convenient_service/utils/hash/triple_equality_compare.rb', line 19

def hash
  @hash
end

#other_hashObject (readonly)

Returns the value of attribute other_hash.



25
26
27
# File 'lib/convenient_service/utils/hash/triple_equality_compare.rb', line 25

def other_hash
  @other_hash
end

Instance Method Details

#callBoolean

Returns:

  • (Boolean)


40
41
42
43
44
45
46
47
# File 'lib/convenient_service/utils/hash/triple_equality_compare.rb', line 40

def call
  return false if hash.size != other_hash.size
  return false if hash.keys.difference(other_hash.keys).any?

  return false unless hash.all? { |key, value| value === other_hash[key] }

  true
end