Class: Hanami::Assets::Config
- Inherits:
-
Object
- Object
- Hanami::Assets::Config
- Includes:
- Dry::Configurable
- Defined in:
- lib/hanami/sprockets/config.rb
Overview
Hanami sprockets configuration.
Instance Attribute Summary collapse
- #asset_paths ⇒ Array<String>
- #base_url ⇒ BaseUrl
-
#cache ⇒ String?
Cache directory path.
-
#compress ⇒ Boolean
Whether to compress assets.
-
#digest ⇒ Boolean
Whether to use fingerprinted asset names.
- #path_prefix ⇒ String
- #precompile ⇒ Array<String>
- #subresource_integrity ⇒ Array<Symbol>
Instance Method Summary collapse
-
#crossorigin?(source) ⇒ Boolean
private
Returns true if the given source is linked via Cross-Origin policy (or in other words, if the given source does not satisfy the Same-Origin policy).
-
#initialize(**values) {|config| ... } ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize(**values) {|config| ... } ⇒ Config
Returns a new instance of Config.
84 85 86 87 88 89 90 |
# File 'lib/hanami/sprockets/config.rb', line 84 def initialize(**values) super() config.update(values.select { |k| _settings.key?(k) }) yield(config) if block_given? end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ Object (private)
110 111 112 113 114 115 116 |
# File 'lib/hanami/sprockets/config.rb', line 110 def method_missing(name, ...) if config.respond_to?(name) config.public_send(name, ...) else super end end |
Instance Attribute Details
#asset_paths ⇒ Array<String>
52 |
# File 'lib/hanami/sprockets/config.rb', line 52 setting :asset_paths, default: [] |
#base_url ⇒ BaseUrl
45 |
# File 'lib/hanami/sprockets/config.rb', line 45 setting :base_url, constructor: -> url { BaseUrl.new(url.to_s) } |
#cache ⇒ String?
Returns Cache directory path.
80 |
# File 'lib/hanami/sprockets/config.rb', line 80 setting :cache, default: nil |
#compress ⇒ Boolean
Returns Whether to compress assets.
73 |
# File 'lib/hanami/sprockets/config.rb', line 73 setting :compress, default: true |
#digest ⇒ Boolean
Returns Whether to use fingerprinted asset names.
66 |
# File 'lib/hanami/sprockets/config.rb', line 66 setting :digest, default: true |
#path_prefix ⇒ String
25 |
# File 'lib/hanami/sprockets/config.rb', line 25 setting :path_prefix, default: "/assets" |
#precompile ⇒ Array<String>
59 |
# File 'lib/hanami/sprockets/config.rb', line 59 setting :precompile, default: %w[*.js *.css *.png *.jpg *.gif *.svg] |
#subresource_integrity ⇒ Array<Symbol>
35 |
# File 'lib/hanami/sprockets/config.rb', line 35 setting :subresource_integrity, default: [] |
Instance Method Details
#crossorigin?(source) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns true if the given source is linked via Cross-Origin policy (or in other words, if the given source does not satisfy the Same-Origin policy).
104 105 106 |
# File 'lib/hanami/sprockets/config.rb', line 104 def crossorigin?(source) base_url.crossorigin?(source) end |