Skip to content

Commit

Permalink
Check if respond to private methods before send.
Browse files Browse the repository at this point in the history
Fixes #475
  • Loading branch information
excid3 committed Jul 31, 2024
1 parent 0430be6 commit 693a64b
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/models/noticed/deliverable/deliver_by.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def evaluate_option(name, context)

if option.respond_to?(:call)
context.instance_exec(&option)
elsif option.is_a?(Symbol) && context.respond_to?(option)
elsif option.is_a?(Symbol) && context.respond_to?(option, true)
context.send(option)
else
option
Expand Down
2 changes: 1 addition & 1 deletion lib/noticed/bulk_delivery_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def evaluate_option(name)
event.instance_exec(&option)

# Call method if symbol and matching method
elsif option.is_a?(Symbol) && event.respond_to?(option)
elsif option.is_a?(Symbol) && event.respond_to?(option, true)
event.send(option)

# Return the value
Expand Down
2 changes: 1 addition & 1 deletion lib/noticed/delivery_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def evaluate_option(name)
notification.instance_exec(&option)

# Call method if symbol and matching method on Notifier
elsif option.is_a?(Symbol) && event.respond_to?(option)
elsif option.is_a?(Symbol) && event.respond_to?(option, true)
event.send(option, notification)

# Return the value
Expand Down
2 changes: 1 addition & 1 deletion lib/noticed/delivery_methods/fcm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def send_notification(device_token)

def format_notification(device_token)
method = config[:json]
if method.is_a?(Symbol) && event.respond_to?(method)
if method.is_a?(Symbol) && event.respond_to?(method, true)
event.send(method, device_token)
else
notification.instance_exec(device_token, &method)
Expand Down
2 changes: 1 addition & 1 deletion lib/noticed/delivery_methods/ios.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def format_notification(apn)

method = config[:format]
# Call method on Notifier if defined
if method&.is_a?(Symbol) && event.respond_to?(method)
if method&.is_a?(Symbol) && event.respond_to?(method, true)
event.send(method, notification, apn)
# If Proc, evaluate it on the Notification
elsif method&.respond_to?(:call)
Expand Down

0 comments on commit 693a64b

Please sign in to comment.