Class: Hanami::Config::Assets

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

Overview

Hanami assets config

This exposes all the settings from the standalone ‘Hanami::Assets` class, pre-configured with sensible defaults for actions within a full Hanami app. It also provides additional settings for further integration of assets with other full stack app components.

Since:

  • 2.1.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**options) ⇒ Assets

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 a new instance of Assets.

Since:

  • 2.1.0



43
44
45
46
47
48
49
# File 'lib/hanami/config/assets.rb', line 43

def initialize(*, **options)
  super()

  @base_config = Hanami::Assets::Config.new(**options)

  configure_defaults
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object (private)

Since:

  • 2.1.0



69
70
71
72
73
74
75
76
77
# File 'lib/hanami/config/assets.rb', line 69

def method_missing(name, *args, &block)
  if config.respond_to?(name)
    config.public_send(name, *args, &block)
  elsif base_config.respond_to?(name)
    base_config.public_send(name, *args, &block)
  else
    super
  end
end

Instance Attribute Details

#serveHanami::Config::Actions::Cookies

Serve static assets.

When this is ‘true`, the app will serve static assets.

If not set, this will:

* Check if the `HANAMI_SERVE_ASSETS` environment variable is set to `"true"`.
* If not, it will check if the app is running in the `development` or `test` environment.

Examples:

config.assets.serve = true

Returns:

Since:

  • 2.1.0



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

setting :serve