Class: Decidim::AssetRouter
- Inherits:
-
Object
- Object
- Decidim::AssetRouter
- Defined in:
- lib/decidim/asset_router.rb
Overview
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) ⇒ AssetRouter
constructor
Initializes the router.
-
#url(**options) ⇒ Object
Generates the correct URL to the asset with the provided options.
Constructor Details
#initialize(asset) ⇒ AssetRouter
Initializes the router.
13 14 15 |
# File 'lib/decidim/asset_router.rb', line 13 def initialize(asset) @asset = asset end |
Instance Method Details
#url(**options) ⇒ Object
Generates the correct URL to the asset with the provided options.
21 22 23 24 25 26 27 |
# File 'lib/decidim/asset_router.rb', line 21 def url(**) if asset.is_a? ActiveStorage::Attached routes.rails_blob_url(asset.blob, **.merge()) else routes.rails_representation_url(asset, **.merge()) end end |