Class: Locale::HashCompare

Inherits:
Object
  • Object
show all
Defined in:
lib/locales_toys/template/locale.rb

Overview

Compares generic values and returns rich diff

Instance Method Summary collapse

Constructor Details

#initialize(hash, other_hash) ⇒ HashCompare

Returns a new instance of HashCompare.



22
23
24
25
# File 'lib/locales_toys/template/locale.rb', line 22

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

Instance Method Details

#different_keysObject



27
28
29
30
31
32
33
34
# File 'lib/locales_toys/template/locale.rb', line 27

def different_keys
  @hash.each_with_object({}) do |(key, value), result|
    difference = generic_difference(value, @other_hash[key])
    next if difference.nil? || difference.empty?

    result[key] = difference
  end
end