Module: Authlogic::Session::Existence::InstanceMethods
- Defined in:
- lib/novelys_authlogic/session/existence.rb
Instance Method Summary collapse
-
#destroy ⇒ Object
Clears all errors and the associated record, you should call this terminate a session, thus requring the user to authenticate again if it is needed.
-
#new_session? ⇒ Boolean
Returns true if the session is new, meaning no action has been taken on it and a successful save has not taken place.
-
#save {|result| ... } ⇒ Object
After you have specified all of the details for your session you can try to save it.
-
#save! ⇒ Object
Same as save but raises an exception of validation errors when validation fails.
Instance Method Details
#destroy ⇒ Object
Clears all errors and the associated record, you should call this terminate a session, thus requring the user to authenticate again if it is needed.
45 46 47 48 49 50 51 52 |
# File 'lib/novelys_authlogic/session/existence.rb', line 45 def destroy before_destroy save_record errors.clear @record = nil after_destroy true end |
#new_session? ⇒ Boolean
Returns true if the session is new, meaning no action has been taken on it and a successful save has not taken place.
56 57 58 |
# File 'lib/novelys_authlogic/session/existence.rb', line 56 def new_session? new_session != false end |
#save {|result| ... } ⇒ Object
After you have specified all of the details for your session you can try to save it. This will run validation checks and find the associated record, if all validation passes. If validation does not pass, the save will fail and the erorrs will be stored in the errors object.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/novelys_authlogic/session/existence.rb', line 63 def save(&block) result = nil if valid? self.record = attempted_record before_save new_session? ? before_create : before_update new_session? ? after_create : after_update after_save save_record self.new_session = false result = true else result = false end yield result if block_given? result end |
#save! ⇒ Object
Same as save but raises an exception of validation errors when validation fails
85 86 87 88 89 |
# File 'lib/novelys_authlogic/session/existence.rb', line 85 def save! result = save raise SessionInvalidError.new(self) unless result result end |