Class: TextFieldType

Inherits:
Cortex::FieldType
  • Object
show all
Defined in:
app/models/text_field_type.rb

Constant Summary collapse

PRIMARY_DATA_KEY =
'text'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#textObject

Returns the value of attribute text.



4
5
6
# File 'app/models/text_field_type.rb', line 4

def text
  @text
end

Instance Method Details

#data=(data_hash) ⇒ Object



23
24
25
# File 'app/models/text_field_type.rb', line 23

def data=(data_hash)
  @text = data_hash[PRIMARY_DATA_KEY]
end

#elasticsearch_mappingObject



11
12
13
# File 'app/models/text_field_type.rb', line 11

def elasticsearch_mapping
  { name: mapping_field_name, type: :string, analyzer: :snowball }
end

#field_item_as_indexed_json_for_field_type(field_item, options = {}) ⇒ Object



27
28
29
30
31
# File 'app/models/text_field_type.rb', line 27

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

#graphql_typeObject



19
20
21
# File 'app/models/text_field_type.rb', line 19

def graphql_type
  types.String
end

#graphql_valueObject



15
16
17
# File 'app/models/text_field_type.rb', line 15

def graphql_value
  text
end