Module: AuthHelpers::Model::Confirmable
- Defined in:
- lib/auth_helpers/model/confirmable.rb
Overview
Adds a module that deals with confirmations.
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
-
#confirm! ⇒ Object
Confirms the record by setting the confirmed at.
-
#confirmed? ⇒ Boolean
Returns true if is not a new record and confirmed_at is not blank.
-
#send_confirmation_instructions(on = :create) ⇒ Object
Send confirmation isntructions in different scenarios.
Class Method Details
.included(base) ⇒ Object
9 10 11 12 |
# File 'lib/auth_helpers/model/confirmable.rb', line 9 def self.included(base) base.extend ClassMethods base.send :after_create, :send_confirmation_instructions end |
Instance Method Details
#confirm! ⇒ Object
Confirms the record by setting the confirmed at.
22 23 24 |
# File 'lib/auth_helpers/model/confirmable.rb', line 22 def confirm! update_attribute(:confirmed_at, Time.now.utc) end |
#confirmed? ⇒ Boolean
Returns true if is not a new record and confirmed_at is not blank.
16 17 18 |
# File 'lib/auth_helpers/model/confirmable.rb', line 16 def confirmed? !(self.new_record? || self.confirmed_at.nil?) end |
#send_confirmation_instructions(on = :create) ⇒ Object
Send confirmation isntructions in different scenarios. It resets the perishable token, confirmed_at date and set the confirmation_sent_at datetime.
30 31 32 33 34 35 36 |
# File 'lib/auth_helpers/model/confirmable.rb', line 30 def send_confirmation_instructions(on=:create) self.reset_perishable_token self.confirmed_at = nil self.confirmation_sent_at = Time.now.utc self.save(false) AuthHelpers::Notifier.send(:"deliver_#{on}_confirmation", self) end |