Class: AssetFieldType
- Inherits:
-
FieldType
- Object
- FieldType
- AssetFieldType
- Defined in:
- app/models/asset_field_type.rb
Instance Attribute Summary collapse
-
#asset ⇒ Object
Returns the value of attribute asset.
-
#asset_content_type ⇒ Object
Returns the value of attribute asset_content_type.
-
#asset_file_name ⇒ Object
Returns the value of attribute asset_file_name.
-
#asset_file_size ⇒ Object
Returns the value of attribute asset_file_size.
-
#asset_updated_at ⇒ Object
Returns the value of attribute asset_updated_at.
-
#dimensions ⇒ Object
readonly
Returns the value of attribute dimensions.
-
#existing_data ⇒ Object
readonly
Returns the value of attribute existing_data.
Instance Method Summary collapse
- #data ⇒ Object
- #data=(data_hash) ⇒ Object
- #field_item_as_indexed_json_for_field_type(field_item, options = {}) ⇒ Object
- #mapping ⇒ Object
- #metadata=(metadata_hash) ⇒ Object
Instance Attribute Details
#asset ⇒ Object
Returns the value of attribute asset.
2 3 4 |
# File 'app/models/asset_field_type.rb', line 2 def asset @asset end |
#asset_content_type ⇒ Object
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_name ⇒ Object
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_size ⇒ Object
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_at ⇒ Object
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 |
#dimensions ⇒ Object (readonly)
Returns the value of attribute dimensions.
8 9 10 |
# File 'app/models/asset_field_type.rb', line 8 def dimensions @dimensions end |
#existing_data ⇒ Object (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
#data ⇒ Object
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, = {}) json = {} json[mapping_field_name] = asset_file_name json end |
#mapping ⇒ Object
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 |