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.
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.
11 12 13 14 |
# File 'lib/fast_gettext/translation_repository/chain.rb', line 11 def initialize(name,={}) super self.chain = [:chain] end |
Instance Attribute Details
#chain ⇒ Object
Returns the value of attribute chain.
9 10 11 |
# File 'lib/fast_gettext/translation_repository/chain.rb', line 9 def chain @chain end |
Instance Method Details
#[](key) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/fast_gettext/translation_repository/chain.rb', line 27 def [](key) chain.each do |c| result = c[key] and return result end nil end |
#available_locales ⇒ Object
16 17 18 |
# File 'lib/fast_gettext/translation_repository/chain.rb', line 16 def available_locales chain.map{|c|c.available_locales}.flatten.uniq end |
#plural(*keys) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/fast_gettext/translation_repository/chain.rb', line 34 def plural(*keys) chain.each do |c| result = c.plural(*keys) return result unless result.compact.empty? end [] end |
#pluralisation_rule ⇒ Object
20 21 22 23 24 25 |
# File 'lib/fast_gettext/translation_repository/chain.rb', line 20 def pluralisation_rule chain.each do |c| result = c.pluralisation_rule and return result end nil end |
#reload ⇒ Object
42 43 44 45 |
# File 'lib/fast_gettext/translation_repository/chain.rb', line 42 def reload chain.each(&:reload) super end |