Class: Headmin::Form::MediaItemView
Instance Method Summary
collapse
Methods inherited from ViewModel
#attributes, #initialize, #to_hash
Constructor Details
This class inherits a constructor from ViewModel
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class ViewModel
Instance Method Details
#attachment ⇒ Object
18
19
20
|
# File 'app/models/headmin/form/media_item_view.rb', line 18
def attachment
form.object
end
|
#content_type ⇒ Object
34
35
36
|
# File 'app/models/headmin/form/media_item_view.rb', line 34
def content_type
attachment.blob&.content_type
end
|
#filename ⇒ Object
30
31
32
|
# File 'app/models/headmin/form/media_item_view.rb', line 30
def filename
attachment.blob&.filename&.to_s
end
|
#id ⇒ Object
26
27
28
|
# File 'app/models/headmin/form/media_item_view.rb', line 26
def id
attachment.blob ? attachment.blob.id : "$1"
end
|
#position_value ⇒ Object
22
23
24
|
# File 'app/models/headmin/form/media_item_view.rb', line 22
def position_value
attachment.new_record? ? nil : attachment.position
end
|
#size ⇒ Object
38
39
40
|
# File 'app/models/headmin/form/media_item_view.rb', line 38
def size
number_to_human_size(attachment.blob&.byte_size || 0)
end
|
#thumbnail_options ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
|
# File 'app/models/headmin/form/media_item_view.rb', line 6
def thumbnail_options
options = {
file: attachment
}
options = options.merge(width: width) if is_defined?(:width)
options = options.merge(height: height) if is_defined?(:height)
options
end
|