Class: Hash

Inherits:
Object show all
Defined in:
lib/like_structure/extensions.rb

Instance Method Summary collapse

Instance Method Details

#reverse_like?(actual) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
25
26
27
28
29
30
31
# File 'lib/like_structure/extensions.rb', line 22

def reverse_like?(actual)
#    expected_keys_wildcards, expected_keys_exact = self.keys.partition{ |k| k.kind_of?(Wildcard) } #TODO wildcards in keys
  expected_keys_exact = self.keys
  actual_keys = Set[*actual.keys]
  return false unless expected_keys_exact.size == actual_keys.size
  expected_keys_exact.each do |key|
    return false unless actual_keys.delete?(key) && actual[key].like?(self[key])
  end
  true
end