Class: Mongoid::Globalize::FieldsBuilder
- Inherits:
-
Object
- Object
- Mongoid::Globalize::FieldsBuilder
- Defined in:
- lib/mongoid_globalize/fields_builder.rb
Instance Method Summary collapse
-
#fallbacks_for_empty_translations! ⇒ Object
Sets
fallbacks_for_empty_translations
option. -
#field(name, *params) ⇒ Object
Creates new field in translation document.
-
#initialize(model) ⇒ FieldsBuilder
constructor
Initializes new istance of FieldsBuilder.
Constructor Details
#initialize(model) ⇒ FieldsBuilder
Initializes new istance of FieldsBuilder. Param Class
5 6 7 |
# File 'lib/mongoid_globalize/fields_builder.rb', line 5 def initialize(model) @model = model end |
Instance Method Details
#fallbacks_for_empty_translations! ⇒ Object
Sets fallbacks_for_empty_translations
option.
19 20 21 |
# File 'lib/mongoid_globalize/fields_builder.rb', line 19 def fallbacks_for_empty_translations! @model.fallbacks_for_empty_translations = true end |
#field(name, *params) ⇒ Object
Creates new field in translation document. Param String or Symbol Other params are the same as for Mongoid’s field
12 13 14 15 16 |
# File 'lib/mongoid_globalize/fields_builder.rb', line 12 def field(name, *params) @model.translated_attribute_names.push name.to_sym @model.translated_attr_accessor(name) @model.translation_class.field name, *params end |