Class: AssetFieldType

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

Constant Summary collapse

VALIDATION_TYPES =
{
  presence: :valid_presence_validation?,
  size: :valid_size_validation?,
  content_type: :valid_content_type_validation?
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#asset_content_typeObject

Returns the value of attribute asset_content_type.



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

def asset_content_type
  @asset_content_type
end

#asset_file_nameObject

Returns the value of attribute asset_file_name.



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

def asset_file_name
  @asset_file_name
end

#asset_file_sizeObject

Returns the value of attribute asset_file_size.



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

def asset_file_size
  @asset_file_size
end

#asset_updated_atObject

Returns the value of attribute asset_updated_at.



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

def asset_updated_at
  @asset_updated_at
end

#dataObject

Returns the value of attribute data.



14
15
16
# File 'app/models/asset_field_type.rb', line 14

def data
  @data
end

#field_nameObject

Returns the value of attribute field_name.



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

def field_name
  @field_name
end

#validationsObject

Returns the value of attribute validations.



14
15
16
# File 'app/models/asset_field_type.rb', line 14

def validations
  @validations
end

Instance Method Details

#acceptable_validations?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'app/models/asset_field_type.rb', line 29

def acceptable_validations?
  valid_types? && valid_options?
end

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



33
34
35
36
37
# File 'app/models/asset_field_type.rb', line 33

def field_item_as_indexed_json_for_field_type(field_item, options = {})
  json = {}
  json[mapping_field_name] = asset_file_name
  json
end

#mappingObject



39
40
41
# File 'app/models/asset_field_type.rb', line 39

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