lib/authtrail.rb in authtrail-0.5.0 vs lib/authtrail.rb in authtrail-0.6.0

- old
+ new

@@ -10,10 +10,18 @@ class << self attr_accessor :exclude_method, :geocode, :track_method, :identity_method, :job_queue, :transform_method end self.geocode = false + self.track_method = lambda do |data| + login_activity = LoginActivity.new + data.each do |k, v| + login_activity.try("#{k}=", v) + end + login_activity.save! + AuthTrail::GeocodeJob.perform_later(login_activity) if AuthTrail.geocode + end self.identity_method = lambda do |request, opts, user| if user user.try(:email) else scope = opts[:scope] @@ -44,19 +52,10 @@ # if exclude_method throws an exception, default to not excluding exclude = AuthTrail.exclude_method && AuthTrail.safely(default: false) { AuthTrail.exclude_method.call(data) } unless exclude - if AuthTrail.track_method - AuthTrail.track_method.call(data) - else - login_activity = LoginActivity.new - data.each do |k, v| - login_activity.try("#{k}=", v) - end - login_activity.save! - AuthTrail::GeocodeJob.perform_later(login_activity) if AuthTrail.geocode - end + AuthTrail.track_method.call(data) end end def self.safely(default: nil) begin