2011-04-13 10:19:51 +00:00
|
|
|
class I18nVariable
|
|
|
|
|
|
|
|
include Mongoid::Document
|
2011-03-08 09:25:46 +00:00
|
|
|
include Mongoid::Timestamps
|
2012-06-20 06:50:51 +00:00
|
|
|
|
2012-07-13 07:36:10 +00:00
|
|
|
field :key, :index => true
|
|
|
|
field :document_class, :type => String, :index => true
|
2011-01-28 06:44:08 +00:00
|
|
|
field :parent_id, :type => BSON::ObjectId, :index => true
|
2011-04-13 10:19:51 +00:00
|
|
|
|
2012-07-13 07:36:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2011-12-23 10:34:21 +00:00
|
|
|
belongs_to :language_value, polymorphic: true
|
|
|
|
|
2012-02-13 11:34:06 +00:00
|
|
|
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
|
2011-06-01 02:24:14 +00:00
|
|
|
end
|
|
|
|
|
2012-02-14 16:32:20 +00:00
|
|
|
def self.from_locale(locale)
|
|
|
|
I18nVariable.first(:conditions => {:key => locale})[I18n.locale]
|
|
|
|
end
|
|
|
|
|
2011-04-13 10:19:51 +00:00
|
|
|
end
|