orbit-basic/app/models/i18n_variable.rb

25 lines
532 B
Ruby

class I18nVariable
include Mongoid::Document
include Mongoid::Timestamps
field :key
field :document_class, :type => String
field :parent_id, :type => BSON::ObjectId, :index => true
belongs_to :language_value, polymorphic: true
def method_missing(*field)
if field.size > 1
self.write_attribute(field[0].to_s.delete('=').to_sym, field[1])
else
self[field[0]]
end
end
def self.from_locale(locale)
I18nVariable.first(:conditions => {:key => locale})[I18n.locale]
end
end