Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix reflex_data keyword argument #673

Merged
merged 2 commits into from
Nov 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/channels/stimulus_reflex/channel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ def receive(data)
delegate_call_to_reflex reflex
rescue => exception
error = exception_with_backtrace(exception)
error_message = "\e[31mReflex #{reflex.data.target} failed: #{error[:message]} [#{reflex.url}]\e[0m\n#{error[:stack]}"

if reflex
error_message = "\e[31mReflex #{reflex.data.target} failed: #{error[:message]} [#{reflex.url}]\e[0m\n#{error[:stack]}"
reflex.rescue_with_handler(exception)
reflex.logger&.error error_message
reflex.broadcast_error data: data, error: "#{exception} #{exception.backtrace.first.split(":in ")[0] if Rails.env.development?}"
else
error_message = "\e[31mReflex failed: #{error[:message]} \e[0m\n#{error[:stack]}"
unless exception.is_a?(StimulusReflex::VersionMismatchError)
StimulusReflex.config.logger.error error_message
end
Expand Down
1 change: 1 addition & 0 deletions lib/stimulus_reflex/reflex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class StimulusReflex::Reflex
# 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, reflex_data:)
@channel = channel
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