Class: AssetFieldType

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#assetObject

Returns the value of attribute asset.



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

def asset
  @asset
end

#asset_content_typeObject

Returns the value of attribute asset_content_type.



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

def asset_content_type
  @asset_content_type
end

#asset_file_nameObject

Returns the value of attribute asset_file_name.



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

def asset_file_name
  @asset_file_name
end

#asset_file_sizeObject

Returns the value of attribute asset_file_size.



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

def asset_file_size
  @asset_file_size
end

#asset_updated_atObject

Returns the value of attribute asset_updated_at.



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

def asset_updated_at
  @asset_updated_at
end

#dimensionsObject (readonly)

Returns the value of attribute dimensions.



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

def dimensions
  @dimensions
end

#existing_dataObject (readonly)

Returns the value of attribute existing_data.



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

def existing_data
  @existing_data
end

Instance Method Details

#dataObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/models/asset_field_type.rb', line 28

def data
  {
    'asset': {
      'file_name': asset_file_name,
      'url': asset.url,
      'style_urls': style_urls,
      'dimensions': dimensions,
      'content_type': asset_content_type,
      'file_size': asset_file_size,
      'updated_at': asset_updated_at
    },
    'media_title': media_title,
    'asset_field_type_id': id
  }
end

#data=(data_hash) ⇒ Object



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

def data=(data_hash)
  self.asset = data_hash.deep_symbolize_keys[:asset]
end

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



44
45
46
47
48
# File 'app/models/asset_field_type.rb', line 44

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

#mappingObject



50
51
52
# File 'app/models/asset_field_type.rb', line 50

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

#metadata=(metadata_hash) ⇒ Object



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

def metadata=()
   = .deep_symbolize_keys
  @existing_data = [:existing_data]
  Paperclip::HasAttachedFile.define_on(self.class, :asset, )
end