Class: TreeFieldType

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#valuesObject

Returns the value of attribute values.



2
3
4
# File 'app/models/tree_field_type.rb', line 2

def values
  @values
end

Instance Method Details

#data=(data_hash) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'app/models/tree_field_type.rb', line 8

def data=(data_hash)
  values = data_hash.deep_symbolize_keys[:values]

  if values.is_a?(Hash)
    @values = values.keys
  else
    @values = [values]
  end
end

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



18
19
20
21
22
# File 'app/models/tree_field_type.rb', line 18

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

#mappingObject



24
25
26
# File 'app/models/tree_field_type.rb', line 24

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