Class: Decidim::AssetRouter::Pipeline
- Inherits:
-
Object
- Object
- Decidim::AssetRouter::Pipeline
- Defined in:
- lib/decidim/asset_router/pipeline.rb
Overview
The pipeline asset router provides global access to the asset routers for assets that are precompiled through the Rails assets pipeline (or webpack) and stored locally or in a remote CDN. This handles the configuration options for the asset routes so that they do not have to be always manually created.
Instance Method Summary collapse
-
#initialize(asset, model: nil) ⇒ Pipeline
constructor
Initializes the router.
-
#url ⇒ String
Generates the correct URL to the asset with the provided options.
Constructor Details
#initialize(asset, model: nil) ⇒ Pipeline
Initializes the router.
18 19 20 21 |
# File 'lib/decidim/asset_router/pipeline.rb', line 18 def initialize(asset, model: nil) @asset = asset @model = model end |
Instance Method Details
#url ⇒ String
Generates the correct URL to the asset with the provided options.
Accepts the options for the URL that are the normal route
Rails route helpers accept
29 30 31 32 33 34 |
# File 'lib/decidim/asset_router/pipeline.rb', line 29 def url(**) path = ActionController::Base.helpers.asset_pack_path(asset, **) return path if path.match?(%r{\A(https?:)?//}) "#{asset_host}#{path}" end |