Class: Bugsnag::Middleware::ClearanceUser
- Inherits:
-
Object
- Object
- Bugsnag::Middleware::ClearanceUser
- Defined in:
- lib/bugsnag/middleware/clearance_user.rb
Constant Summary collapse
- COMMON_USER_FIELDS =
[:email, :name, :first_name, :last_name, :created_at, :id]
Instance Method Summary collapse
- #call(notification) ⇒ Object
-
#initialize(bugsnag) ⇒ ClearanceUser
constructor
A new instance of ClearanceUser.
Constructor Details
#initialize(bugsnag) ⇒ ClearanceUser
Returns a new instance of ClearanceUser.
5 6 7 |
# File 'lib/bugsnag/middleware/clearance_user.rb', line 5 def initialize(bugsnag) @bugsnag = bugsnag end |
Instance Method Details
#call(notification) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/bugsnag/middleware/clearance_user.rb', line 9 def call(notification) if notification.request_data[:rack_env] && notification.request_data[:rack_env][:clearance] && notification.request_data[:rack_env][:clearance].signed_in? && notification.request_data[:rack_env][:clearance].current_user # Extract useful user information user = {} user_object = notification.request_data[:rack_env][:clearance].current_user if user_object # Build the bugsnag user info from the current user record COMMON_USER_FIELDS.each do |field| user[field] = user_object.send(field) if user_object.respond_to?(field) end end notification.user = user unless user.empty? end @bugsnag.call(notification) end |