class Elasticsearch::Model::MongoidExtensions::Localized::ProcessMappings
Public Class Methods
call(*args)
click to toggle source
# File lib/elasticsearch/model/mongoid_extensions/localized.rb, line 10 def self.call(*args) new(*args).call end
Public Instance Methods
call()
click to toggle source
# File lib/elasticsearch/model/mongoid_extensions/localized.rb, line 14 def call mapping.each do |field_name, options| next unless field = cls.fields[field_name.to_s] || cls.fields.detect { |_, meta| meta.options[: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] = options.dup end mapping[field_name].freeze end mapping end