Class: Mongoid::Fields::Localized
- Inherits:
-
Standard
- Object
- Standard
- 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)
-
- (Object) demongoize(object)
Demongoize the object based on the current locale.
-
- (true, false) localized?
Is the field localized or not?.
-
- (Hash) mongoize(object)
Convert the provided string into a hash for the locale.
Methods inherited from Standard
#add_atomic_changes, #constraint, #demongoized_identity_for, #eval_default, #foreign_key?, #initialize, #metadata, #object_id_field?, #pre_processed?, #type, #versioned?
Constructor Details
This class inherits a constructor from Mongoid::Fields::Standard
Instance Method Details
- (Object) demongoize(object)
Demongoize the object based on the current locale. Will look in the hash for the current locale.
17 18 19 20 |
# File 'lib/mongoid/fields/localized.rb', line 17 def demongoize(object) return nil if object.nil? type.demongoize(lookup(object)) end |
- (true, false) localized?
Is the field localized or not?
30 31 32 |
# File 'lib/mongoid/fields/localized.rb', line 30 def localized? true end |
- (Hash) mongoize(object)
Convert the provided string into a hash for the locale.
44 45 46 |
# File 'lib/mongoid/fields/localized.rb', line 44 def mongoize(object) { ::I18n.locale.to_s => type.mongoize(object) } end |