lib/hanami/extensions/action/slice_configured_action.rb in hanami-2.0.0.beta4 vs lib/hanami/extensions/action/slice_configured_action.rb in hanami-2.0.0.rc1

- old
+ new

@@ -1,9 +1,7 @@ # frozen_string_literal: true -require "hanami/action" - module Hanami module Extensions module Action # Provides slice-specific configuration and behavior for any action class defined # within a slice's module namespace. @@ -33,16 +31,18 @@ # @see Hanami::Extensions::Action::InstanceMethods#initialize def define_new resolve_view = method(:resolve_paired_view) resolve_view_context = method(:resolve_view_context) resolve_routes = method(:resolve_routes) + resolve_rack_monitor = method(:resolve_rack_monitor) define_method(:new) do |**kwargs| super( view: kwargs.fetch(:view) { resolve_view.(self) }, view_context: kwargs.fetch(:view_context) { resolve_view_context.() }, routes: kwargs.fetch(:routes) { resolve_routes.() }, + rack_monitor: kwargs.fetch(:rack_monitor) { resolve_rack_monitor.() }, **kwargs, ) end end @@ -84,16 +84,16 @@ # class, leaving `MySlice::Actions::SomeAction` with `config.default_response_format` of # `:html` (the default at `Hanami.app.config.actions.default_response_format`), and not # the `:json` value configured in its immediate superclass. # # This would be surprising behavior, and we want to avoid it. - slice_value = slice.config.actions.public_send(:"#{setting}") - parent_value = slice.parent.config.actions.public_send(:"#{setting}") if slice.parent + slice_value = slice.config.actions.public_send(setting.name) + parent_value = slice.parent.config.actions.public_send(setting.name) if slice.parent next if slice.parent && slice_value == parent_value - action_class.config.public_send(:"#{setting}=", slice_value) + action_class.config.public_send(:"#{setting.name}=", slice_value) end end def extend_behavior(action_class) if actions_config.sessions.enabled? @@ -133,9 +133,13 @@ end end def resolve_routes slice.app["routes"] if slice.app.key?("routes") + end + + def resolve_rack_monitor + slice.app["rack.monitor"] if slice.app.key?("rack.monitor") end def actions_config slice.config.actions end