Class: Alchemy::StorageAdapter::ActiveStorage::PictureUrl
- Inherits:
-
Object
- Object
- Alchemy::StorageAdapter::ActiveStorage::PictureUrl
- Defined in:
- app/models/alchemy/storage_adapter/active_storage/picture_url.rb
Overview
Returns the URL to a variant of a picture using ActiveStorage
Instance Attribute Summary collapse
-
#image_file ⇒ Object
readonly
Returns the value of attribute image_file.
-
#picture ⇒ Object
readonly
Returns the value of attribute picture.
Instance Method Summary collapse
-
#call(options = {}) ⇒ String
The URL to a variant of a picture.
-
#initialize(picture) ⇒ PictureUrl
constructor
A new instance of PictureUrl.
Constructor Details
#initialize(picture) ⇒ PictureUrl
Returns a new instance of PictureUrl.
11 12 13 14 |
# File 'app/models/alchemy/storage_adapter/active_storage/picture_url.rb', line 11 def initialize(picture) @picture = picture @image_file = picture.image_file end |
Instance Attribute Details
#image_file ⇒ Object (readonly)
Returns the value of attribute image_file.
7 8 9 |
# File 'app/models/alchemy/storage_adapter/active_storage/picture_url.rb', line 7 def image_file @image_file end |
#picture ⇒ Object (readonly)
Returns the value of attribute picture.
7 8 9 |
# File 'app/models/alchemy/storage_adapter/active_storage/picture_url.rb', line 7 def picture @picture end |
Instance Method Details
#call(options = {}) ⇒ String
The URL to a variant of a picture
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/models/alchemy/storage_adapter/active_storage/picture_url.rb', line 20 def call( = {}) = DragonflyToImageProcessing.call() [:format] = [:format] || default_output_format variant = image_file&.variant() return unless variant Rails.application.routes.url_helpers.rails_blob_path( variant, { filename: filename(), format: [:format], only_path: true } ) end |