Class: Hanami::Assets::Config

Inherits:
Object
  • Object
show all
Includes:
Dry::Configurable
Defined in:
lib/hanami/assets/config.rb

Overview

Hanami assets configuration.

Since:

  • 0.1.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**values) {|config| ... } ⇒ Config

Returns a new instance of Config.

Yields:

Since:

  • 2.1.0



56
57
58
59
60
61
62
# File 'lib/hanami/assets/config.rb', line 56

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)

Since:

  • 0.1.0



82
83
84
85
86
87
88
# File 'lib/hanami/assets/config.rb', line 82

def method_missing(name, ...)
  if config.respond_to?(name)
    config.public_send(name, ...)
  else
    super
  end
end

Instance Attribute Details

#base_urlBaseUrl

Examples:

config.base_url = "http://some-cdn.com/assets"

Returns:

Since:

  • 2.1.0



52
# File 'lib/hanami/assets/config.rb', line 52

setting :base_url, constructor: -> url { BaseUrl.new(url.to_s) }

#node_commandString

Returns:

  • (String)

Since:

  • 2.1.0



25
# File 'lib/hanami/assets/config.rb', line 25

setting :node_command, default: "node"

#path_prefixString

Returns:

  • (String)

Since:

  • 2.1.0



32
# File 'lib/hanami/assets/config.rb', line 32

setting :path_prefix, default: "/assets"

#subresource_integrityArray<Symbol>

Examples:

config.subresource_integrity # => [:sha256, :sha512]

Returns:

  • (Array<Symbol>)

Since:

  • 2.1.0



42
# File 'lib/hanami/assets/config.rb', line 42

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).



76
77
78
# File 'lib/hanami/assets/config.rb', line 76

def crossorigin?(source)
  base_url.crossorigin?(source)
end