Class: I18n::Hygiene::KeysWithMatchedValue

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/i18n/hygiene/keys_with_matched_value.rb

Overview

Checks to see if any i18n values match a given regex.

Instance Method Summary collapse

Constructor Details

#initialize(regex, i18n_wrapper = nil, reject_keys: nil) ⇒ KeysWithMatchedValue

Returns a new instance of KeysWithMatchedValue.



7
8
9
10
11
# File 'lib/i18n/hygiene/keys_with_matched_value.rb', line 7

def initialize(regex, i18n_wrapper = nil, reject_keys: nil)
  @regex = regex
  @i18n = i18n_wrapper || I18n::Hygiene::Wrapper.new(exclude_keys: [])
  @reject_keys = reject_keys
end

Instance Method Details

#each(&block) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/i18n/hygiene/keys_with_matched_value.rb', line 13

def each(&block)
  locales.each do |locale|
    matching_keys(locale).each do |key|
      block.call(locale, key)
    end
  end
end