Module: I18n::Backend::Moped::Implementation
Instance Attribute Summary collapse
-
#collection ⇒ Object
Returns the value of attribute collection.
Instance Method Summary collapse
- #available_locales ⇒ Object
- #initialize(collection, options = {}) ⇒ Object
- #store_translations(locale, data, options = {}) ⇒ Object
Instance Attribute Details
#collection ⇒ Object
Returns the value of attribute collection.
7 8 9 |
# File 'lib/i18n/backend/moped.rb', line 7 def collection @collection end |
Instance Method Details
#available_locales ⇒ Object
14 15 16 |
# File 'lib/i18n/backend/moped.rb', line 14 def available_locales collection.find.distinct(:locale).map {|l| l.to_sym} end |
#initialize(collection, options = {}) ⇒ Object
10 11 12 |
# File 'lib/i18n/backend/moped.rb', line 10 def initialize(collection, ={}) @collection, @options = collection, end |
#store_translations(locale, data, options = {}) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/i18n/backend/moped.rb', line 18 def store_translations(locale, data, = {}) escape = .fetch(:escape, true) flatten_translations(locale, data, escape, false).each do |key, value| collection.find(:key => key.to_s, :locale => locale.to_s).remove_all doc = {:key => key.to_s, :value => value, :locale => locale.to_s} collection.insert(doc) end end |