Class: TreeFieldType

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

Constant Summary collapse

VALIDATION_TYPES =
{
  presence: :valid_presence_validation?,
  maximum: :valid_maximum_validation?,
  minimum: :valid_minimum_validation?
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dataObject

Returns the value of attribute data.



8
9
10
# File 'app/models/tree_field_type.rb', line 8

def data
  @data
end

#field_nameObject

Returns the value of attribute field_name.



8
9
10
# File 'app/models/tree_field_type.rb', line 8

def field_name
  @field_name
end

#metadataObject

Returns the value of attribute metadata.



9
10
11
# File 'app/models/tree_field_type.rb', line 9

def 
  
end

#validationsObject

Returns the value of attribute validations.



9
10
11
# File 'app/models/tree_field_type.rb', line 9

def validations
  @validations
end

#valuesObject

Returns the value of attribute values.



8
9
10
# File 'app/models/tree_field_type.rb', line 8

def values
  @values
end

Instance Method Details

#acceptable_validations?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'app/models/tree_field_type.rb', line 33

def acceptable_validations?
  valid_types? && valid_options?
end

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



37
38
39
40
41
# File 'app/models/tree_field_type.rb', line 37

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

#mappingObject



43
44
45
# File 'app/models/tree_field_type.rb', line 43

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