Class: Integral::Storage::FileDecorator
- Inherits:
-
BaseDecorator
- Object
- Draper::Decorator
- BaseDecorator
- Integral::Storage::FileDecorator
- Defined in:
- app/decorators/integral/storage/file_decorator.rb
Overview
Storage File view-level logic
Instance Method Summary collapse
- #image_url(size: nil, transform: nil, fallback: true) ⇒ Object
-
#to_backend_card ⇒ Hash
The instance as a card.
Methods inherited from BaseDecorator
#activity_url, #backend_url, #edit_backend_url, #render_active_block_list
Instance Method Details
#image_url(size: nil, transform: nil, fallback: true) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/decorators/integral/storage/file_decorator.rb', line 7 def image_url(size: nil, transform: nil, fallback: true) representation = if size .representation(Integral..merge!(resize_to_limit: Integral.image_sizes[size])) elsif transform .representation(transform) else .representation(Integral..merge!(resize_to_limit: Integral.image_sizes[:medium])) end app_url_helpers.url_for(representation) end |
#to_backend_card ⇒ Hash
Returns the instance as a card.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/decorators/integral/storage/file_decorator.rb', line 20 def to_backend_card attributes = [ { key: I18n.t('integral.records.attributes.type'), value: .content_type }, { key: I18n.t('integral.records.attributes.size'), value: h.number_to_human_size(.byte_size) }, { key: I18n.t('integral.records.attributes.updated_at'), value: I18n.l(updated_at) }, { key: I18n.t('integral.records.attributes.created_at'), value: I18n.l(created_at) } ] { image: image_url, description: description, url: backend_url, attributes: attributes } end |