lib/stimulus_reflex/reflex.rb in stimulus_reflex-3.4.0.pre7 vs lib/stimulus_reflex/reflex.rb in stimulus_reflex-3.4.0.pre8

- old
+ new

@@ -47,13 +47,14 @@ attr_reader :cable_ready, :channel, :url, :element, :selectors, :method_name, :broadcaster, :client_attributes, :logger alias_method :action_name, :method_name # for compatibility with controller libraries like Pundit that expect an action name delegate :connection, :stream_name, to: :channel - delegate :flash, :session, to: :request + delegate :controller_class, :flash, :session, to: :request delegate :broadcast, :broadcast_message, to: :broadcaster delegate :reflex_id, :reflex_controller, :xpath, :c_xpath, :permanent_attribute_name, to: :client_attributes + delegate :render, to: :controller_class def initialize(channel, url: nil, element: nil, selectors: [], method_name: nil, params: {}, client_attributes: {}) @channel = channel @url = url @element = element @@ -112,14 +113,14 @@ end end def controller @controller ||= begin - request.controller_class.new.tap do |c| + controller_class.new.tap do |c| c.instance_variable_set :"@stimulus_reflex", true instance_variables.each { |name| c.instance_variable_set name, instance_variable_get(name) } - c.request = request - c.response = ActionDispatch::Response.new + c.set_request! request + c.set_response! controller_class.make_response!(request) end end end def process(name, *args)