Skip to content

Commit

Permalink
Don't call #send when method name is nil
Browse files Browse the repository at this point in the history
  • Loading branch information
gkampjes committed Jun 15, 2023
1 parent 32d7856 commit 02a547a
Showing 1 changed file with 22 additions and 25 deletions.
47 changes: 22 additions & 25 deletions lib/rollbar/plugins/rails/controller_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,30 @@ module ControllerMethods
include RequestDataExtractor

def rollbar_person_data
user = nil
unless Rollbar::Util.method_in_stack_twice(:rollbar_person_data, __FILE__)
user = send(Rollbar.configuration.person_method)
end
return {} if Rollbar::Util.method_in_stack_twice(:rollbar_person_data, __FILE__)

config = Rollbar.configuration
user = send(config.person_method)
return {} unless user

# include id, username, email if non-empty
if user
{
:id => (begin
user.send(Rollbar.configuration.person_id_method)
rescue StandardError
nil
end),
:username => (begin
user.send(Rollbar.configuration.person_username_method)
rescue StandardError
nil
end),
:email => (begin
user.send(Rollbar.configuration.person_email_method)
rescue StandardError
nil
end)
}
else
{}
end
{
:id => (begin
user.send(config.person_id_method) if config.person_id_method
rescue StandardError
nil
end),
:username => (begin
user.send(config.person_username_method) if config.person_username_method
rescue StandardError
nil
end),
:email => (begin
user.send(config.person_email_method) if config.person_email_method
rescue StandardError
nil
end)
}
rescue NameError
{}
end
Expand Down

0 comments on commit 02a547a

Please sign in to comment.