Module: I18n::Backend::Moped::Implementation

Includes:
Base, Flatten
Included in:
I18n::Backend::Moped
Defined in:
lib/i18n/backend/moped.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#collectionObject

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_localesObject



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, options={})
  @collection, @options = collection, options
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, options = {})
  escape = options.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