class Raygun::AffectedUser
Constants
- DEFAULT_MAPPING
- NAME_TO_RAYGUN_NAME_MAPPING
- SUPPORTED_ATTRIBUTES
Public Class Methods
information_hash(user_object)
click to toggle source
# File lib/raygun/affected_user.rb, line 21 def information_hash(user_object) if user_object.nil? || user_object.is_a?(String) handle_anonymous_user(user_object) else handle_known_user(user_object) end end
Private Class Methods
handle_anonymous_user(user_object)
click to toggle source
# File lib/raygun/affected_user.rb, line 31 def handle_anonymous_user(user_object) result = { isAnonymous: true } result[:identifier] = user_object unless user_object.nil? result end
handle_known_user(user_object)
click to toggle source
# File lib/raygun/affected_user.rb, line 37 def handle_known_user(user_object) SUPPORTED_ATTRIBUTES.reduce({ isAnonymous: false }) do |result, attribute| mapping = Raygun.configuration.affected_user_mapping method = mapping[attribute] value = if method.is_a? Proc method.call(user_object) else attributes = Array(method) attribute_to_use = attributes.select do |attr| user_object.respond_to?(attr, true) end.first user_object.send(attribute_to_use) unless attribute_to_use == nil end result[NAME_TO_RAYGUN_NAME_MAPPING[attribute]] = value unless value == nil result end end