Class: Elasticsearch::Model::MongoidExtensions::Localized::ProcessMappings
- Inherits:
-
Struct
- Object
- Struct
- Elasticsearch::Model::MongoidExtensions::Localized::ProcessMappings
- Defined in:
- lib/elasticsearch/model/mongoid_extensions/localized.rb
Instance Attribute Summary collapse
-
#cls ⇒ Object
Returns the value of attribute cls.
-
#mapping ⇒ Object
Returns the value of attribute mapping.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#cls ⇒ Object
Returns the value of attribute cls
9 10 11 |
# File 'lib/elasticsearch/model/mongoid_extensions/localized.rb', line 9 def cls @cls end |
#mapping ⇒ Object
Returns the value of attribute mapping
9 10 11 |
# File 'lib/elasticsearch/model/mongoid_extensions/localized.rb', line 9 def mapping @mapping end |
Class Method Details
.call(*args) ⇒ Object
10 11 12 |
# File 'lib/elasticsearch/model/mongoid_extensions/localized.rb', line 10 def self.call(*args) new(*args).call end |
Instance Method Details
#call ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/elasticsearch/model/mongoid_extensions/localized.rb', line 14 def call mapping.each do |field_name, | next unless field = cls.fields[field_name.to_s] || cls.fields.detect { |_, | .[:as] == field_name.to_sym }.try(:last) next unless field.localized? next if mapping[field_name]&.frozen? mapping[field_name] = ::I18n.available_locales.each_with_object({ type: 'object', properties: {} }) do |locale, res| res[:properties][locale] = .dup end mapping[field_name].freeze end mapping end |