Class: Formstrap::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
17
18
19
|
# File 'app/models/formstrap/media_item_view.rb', line 17
def attachment
form.object
end
|
#content_type ⇒ Object
33
34
35
|
# File 'app/models/formstrap/media_item_view.rb', line 33
def content_type
attachment.blob&.content_type
end
|
#filename ⇒ Object
29
30
31
|
# File 'app/models/formstrap/media_item_view.rb', line 29
def filename
attachment.blob&.filename&.to_s
end
|
#id ⇒ Object
25
26
27
|
# File 'app/models/formstrap/media_item_view.rb', line 25
def id
attachment.blob ? attachment.blob.id : "$1"
end
|
#position_value ⇒ Object
21
22
23
|
# File 'app/models/formstrap/media_item_view.rb', line 21
def position_value
attachment.new_record? ? nil : attachment.position
end
|
#size ⇒ Object
37
38
39
|
# File 'app/models/formstrap/media_item_view.rb', line 37
def size
number_to_human_size(attachment.blob&.byte_size || 0)
end
|
#thumbnail_options ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
|
# File 'app/models/formstrap/media_item_view.rb', line 5
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
|