Class: FastGettext::TranslationRepository::Chain
- Defined in:
- lib/fast_gettext/translation_repository/chain.rb
Overview
Responsibility:
- delegate calls to members of the chain in turn
TODO cache should be expired after a repo was added
Instance Attribute Summary collapse
-
#chain ⇒ Object
Returns the value of attribute chain.
Attributes inherited from Base
Instance Method Summary collapse
- #[](key) ⇒ Object
- #available_locales ⇒ Object
-
#initialize(name, options = {}) ⇒ Chain
constructor
A new instance of Chain.
- #plural(*keys) ⇒ Object
- #pluralisation_rule ⇒ Object
- #reload ⇒ Object
Constructor Details
#initialize(name, options = {}) ⇒ Chain
Returns a new instance of Chain.
13 14 15 16 |
# File 'lib/fast_gettext/translation_repository/chain.rb', line 13 def initialize(name, = {}) super self.chain = [:chain] end |
Instance Attribute Details
#chain ⇒ Object
Returns the value of attribute chain.
11 12 13 |
# File 'lib/fast_gettext/translation_repository/chain.rb', line 11 def chain @chain end |
Instance Method Details
#[](key) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/fast_gettext/translation_repository/chain.rb', line 31 def [](key) chain.each do |c| if result = c[key] return result end end nil end |
#available_locales ⇒ Object
18 19 20 |
# File 'lib/fast_gettext/translation_repository/chain.rb', line 18 def available_locales chain.map(&:available_locales).flatten.uniq end |
#plural(*keys) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/fast_gettext/translation_repository/chain.rb', line 40 def plural(*keys) chain.each do |c| result = c.plural(*keys) return result unless result.compact.empty? end [] end |
#pluralisation_rule ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/fast_gettext/translation_repository/chain.rb', line 22 def pluralisation_rule chain.each do |c| if result = c.pluralisation_rule return result end end nil end |
#reload ⇒ Object
48 49 50 51 |
# File 'lib/fast_gettext/translation_repository/chain.rb', line 48 def reload chain.each(&:reload) super end |