class Hanami::Config::Actions
Hanami
actions config
This exposes all the settings from the standalone ‘Hanami::Action` class, pre-configured with sensible defaults for actions within a full Hanami
app. It also provides additional settings for further integration of actions with other full stack app components.
@since 2.0.0 @api public
Attributes
base_config[R]
@api private
content_security_policy[RW]
Returns the Content Security Policy config for actions.
The resulting policy is set as a default ‘“Content-Security-Policy”` response header.
@return [Hanami::Config::Actions::ContentSecurityPolicy]
@api public @since 2.0.0
Public Class Methods
new(*, **options)
click to toggle source
@api private
Calls superclass method
# File lib/hanami/config/actions.rb, line 111 def initialize(*, **options) super() @base_config = Hanami::Action.config.dup @content_security_policy = ContentSecurityPolicy.new configure_defaults end
Public Instance Methods
finalize!(app_config)
click to toggle source
@api private
# File lib/hanami/config/actions.rb, line 129 def finalize!(app_config) @base_config.root_directory = app_config.root # A nil value for `csrf_protection` means it has not been explicitly configured # (neither true nor false), so we can default it to whether sessions are enabled self.csrf_protection = sessions.enabled? if csrf_protection.nil? if content_security_policy default_headers["Content-Security-Policy"] = content_security_policy.to_s end end
Private Instance Methods
configure_defaults()
click to toggle source
Apply defaults for base config
# File lib/hanami/config/actions.rb, line 144 def configure_defaults self.default_headers = { "X-Frame-Options" => "DENY", "X-Content-Type-Options" => "nosniff", "X-XSS-Protection" => "1; mode=block" } end
initialize_copy(source)
click to toggle source
@api private
Calls superclass method
# File lib/hanami/config/actions.rb, line 121 def initialize_copy(source) super @base_config = source.base_config.dup @content_security_policy = source.content_security_policy.dup end
method_missing(name, *args, &block)
click to toggle source
Calls superclass method
# File lib/hanami/config/actions.rb, line 152 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
respond_to_missing?(name, _include_all = false)
click to toggle source
Calls superclass method
# File lib/hanami/config/actions.rb, line 162 def respond_to_missing?(name, _include_all = false) config.respond_to?(name) || base_config.respond_to?(name) || super end