Sha256: 3c29c534a4d9bca2d7799d6c64348125b0426752d8a4282cb7344d2525e473c7

Contents?: true

Size: 542 Bytes

Versions: 2

Compression:

Stored size: 542 Bytes

Contents

class ContentItemFieldType < FieldType
  attr_accessor :content_item_id

  def elasticsearch_mapping
    { name: mapping_field_name, type: :keyword, index: :not_analyzed }
  end

  def data=(data_hash)
    @content_item_id = data_hash['content_item_id']
  end

  def field_item_as_indexed_json_for_field_type(field_item, options = {})
    json = {}
    json[mapping_field_name] = field_item.data['content_item_id']
    json
  end

  private

  def mapping_field_name
    "#{field_name.parameterize(separator: '_')}_content_item_id"
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cortex-plugins-core-2.1.1 app/models/content_item_field_type.rb
cortex-plugins-core-2.1.0 app/models/content_item_field_type.rb