class FastGettext::TranslationRepository::Chain

Responsibility:

- delegate calls to members of the chain in turn

TODO cache should be expired after a repo was added

Attributes

chain[RW]

Public Class Methods

new(name, options = {}) click to toggle source
# File lib/fast_gettext/translation_repository/chain.rb, line 12
def initialize(name, options = {})
  super
  self.chain = options[:chain]
end

Public Instance Methods

[](key) click to toggle source
# File lib/fast_gettext/translation_repository/chain.rb, line 30
def [](key)
  chain.each do |c|
    if result = c[key]
      return result
    end
  end
  nil
end
available_locales() click to toggle source
# File lib/fast_gettext/translation_repository/chain.rb, line 17
def available_locales
  chain.map(&:available_locales).flatten.uniq
end
plural(*keys) click to toggle source
# File lib/fast_gettext/translation_repository/chain.rb, line 39
def plural(*keys)
  chain.each do |c|
    result = c.plural(*keys)
    return result unless result.compact.empty?
  end
  []
end
pluralisation_rule() click to toggle source
# File lib/fast_gettext/translation_repository/chain.rb, line 21
def pluralisation_rule
  chain.each do |c|
    if result = c.pluralisation_rule
      return result
    end
  end
  nil
end
reload() click to toggle source
# File lib/fast_gettext/translation_repository/chain.rb, line 47
def reload
  chain.each(&:reload)
  super
end