module Authlogic::ActsAsAuthentic::EmailToken::Methods
Public Class Methods
included(klass)
click to toggle source
# File lib/authlogic/acts_as_authentic/email_token.rb, line 55 def self.included(klass) # Do nothing if the email_token column is missing. If the email_token column # is present but not email_token_updated_at, raise. if !klass.column_names.map(&:to_s).include? 'email_token' return elsif !klass.column_names.map(&:to_s).include? 'email_token_updated_at' raise( ::Authlogic::ActsAsAuthentic::EmailToken::DBStructureError, "#{klass.name} has an email_token column but not email_token_updated_at. " + " You must add the latter. (Should be :datetime, null: false.)" ) end klass.class_eval do extend ClassMethods include InstanceMethods # If this module is added to an existing app, the email_confirmation column will # initially be blank. To avoid errors upon save, we must phase in the new tokens. # # Similarly, when new records are created, we must set these values. before_save ->(user) { if user.email_token.blank? or user.email_token_updated_at.blank? user.reset_email_token end } end end