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:



37
38
39
40
# File 'lib/convenient_service/utils/hash/triple_equality_compare.rb', line 37

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

Instance Attribute Details

#hashObject (readonly)

Returns the value of attribute hash.



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

def hash
  @hash
end

#other_hashObject (readonly)

Returns the value of attribute other_hash.



30
31
32
# File 'lib/convenient_service/utils/hash/triple_equality_compare.rb', line 30

def other_hash
  @other_hash
end

Instance Method Details

#callBoolean

Returns:

  • (Boolean)


45
46
47
48
49
50
51
52
# File 'lib/convenient_service/utils/hash/triple_equality_compare.rb', line 45

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