Class: Decidim::AssetRouter::Storage
- Inherits:
-
Object
- Object
- Decidim::AssetRouter::Storage
- Defined in:
- lib/decidim/asset_router/storage.rb
Overview
Storage asset router provides global access to the asset routes for assets saved through ActiveStorage. This handles the different cases for routing to the remote routes when using an assets CDN or to local routes when using the local disk storage driver.
Instance Method Summary collapse
-
#initialize(asset) ⇒ Storage
constructor
Initializes the router.
-
#url(**options) ⇒ Object
Generates the correct URL to the asset with the provided options.
Constructor Details
#initialize(asset) ⇒ Storage
Initializes the router.
14 15 16 |
# File 'lib/decidim/asset_router/storage.rb', line 14 def initialize(asset) @asset = asset end |
Instance Method Details
#url(**options) ⇒ Object
Generates the correct URL to the asset with the provided options.
22 23 24 25 26 27 28 |
# File 'lib/decidim/asset_router/storage.rb', line 22 def url(**) if asset.is_a? ActiveStorage::Attached routes.rails_blob_url(asset.blob, **.merge()) else routes.rails_representation_url(asset, **.merge()) end end |