Class: Mongoid::Fields::Localized
- Defined in:
- lib/mongoid/fields/localized.rb
Instance Attribute Summary
Attributes inherited from Standard
#default_val, #label, #name, #options
Instance Method Summary collapse
-
#demongoize(object) ⇒ Object
Demongoize the object based on the current locale.
-
#localized? ⇒ true, false
Is the field localized or not?.
-
#mongoize(object) ⇒ Hash
Convert the provided string into a hash for the locale.
Methods inherited from Standard
#add_atomic_changes, #association, #eval_default, #foreign_key?, #initialize, #lazy?, #object_id_field?, #pre_processed?, #type
Constructor Details
This class inherits a constructor from Mongoid::Fields::Standard
Instance Method Details
#demongoize(object) ⇒ Object
Demongoize the object based on the current locale. Will look in the hash for the current locale.
16 17 18 19 20 |
# File 'lib/mongoid/fields/localized.rb', line 16 def demongoize(object) if object type.demongoize(lookup(object)) end end |
#localized? ⇒ true, false
Is the field localized or not?
28 29 30 |
# File 'lib/mongoid/fields/localized.rb', line 28 def localized? true end |
#mongoize(object) ⇒ Hash
Convert the provided string into a hash for the locale.
40 41 42 |
# File 'lib/mongoid/fields/localized.rb', line 40 def mongoize(object) { ::I18n.locale.to_s => type.mongoize(object) } end |