Skip to content

Commit

Permalink
less impact on existing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoenten committed Oct 23, 2023
1 parent 8d754b8 commit 09cadff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions lib/stimulus_reflex/reflex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,22 @@ class StimulusReflex::Reflex
include CableReady::Identifiable

attr_accessor :payload, :headers
attr_reader :channel, :data, :broadcaster
attr_reader :channel, :reflex_data, :broadcaster

delegate :connection, :stream_name, to: :channel
delegate :controller_class, :flash, :session, to: :request
delegate :broadcast, :broadcast_halt, :broadcast_forbid, :broadcast_error, to: :broadcaster

# TODO remove xpath_controller and xpath_element for v4
delegate :url, :element, :selectors, :method_name, :id, :tab_id, :reflex_controller, :xpath_controller, :xpath_element, :permanent_attribute_name, :version, :npm_version, :suppress_logging, to: :data
delegate :url, :element, :selectors, :method_name, :id, :tab_id, :reflex_controller, :xpath_controller, :xpath_element, :permanent_attribute_name, :version, :npm_version, :suppress_logging, to: :reflex_data
# END TODO: remove

alias_method :action_name, :method_name # for compatibility with controller libraries like Pundit that expect an action name
alias_method :data, :reflex_data

def initialize(channel, data:)
def initialize(channel, reflex_data:)
@channel = channel
@data = data
@reflex_data = reflex_data
@broadcaster = StimulusReflex::PageBroadcaster.new(self)
@payload = {}
@headers = {}
Expand Down Expand Up @@ -75,7 +76,7 @@ def request
req = ActionDispatch::Request.new(env)

# fetch path params (controller, action, ...) and apply them
request_params = StimulusReflex::RequestParameters.new(params: data.params, req: req, url: url)
request_params = StimulusReflex::RequestParameters.new(params: reflex_data.params, req: req, url: url)
req = request_params.apply!

req
Expand Down
2 changes: 1 addition & 1 deletion lib/stimulus_reflex/reflex_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def initialize(channel, data)
end

def call
reflex_class.new(channel, data: data)
reflex_class.new(channel, reflex_data: data)
end

private
Expand Down

0 comments on commit 09cadff

Please sign in to comment.