Module: Authgasm::Session::Callbacks
- Included in:
- Base
- Defined in:
- lib/authgasm/session/callbacks.rb
Overview
Callbacks
Just like in ActiveRecord you have before_save, before_validation, etc. You have similar callbacks with Authgasm, see all callbacks below.
Constant Summary collapse
- CALLBACKS =
%w(before_create after_create before_destroy after_destroy before_save after_save before_update after_update before_validation after_validation)
Class Method Summary collapse
-
.included(base) ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#destroy_with_callbacks ⇒ Object
:nodoc:.
-
#save_with_callbacks ⇒ Object
:nodoc:.
- #valid_with_callbacks? ⇒ Boolean
-
#validate_credentials_with_callbacks ⇒ Object
:nodoc:.
Class Method Details
.included(base) ⇒ Object
:nodoc:
9 10 11 12 13 14 15 16 |
# File 'lib/authgasm/session/callbacks.rb', line 9 def self.included(base) #:nodoc: [:destroy, :save, :valid?, :validate_credentials].each do |method| base.send :alias_method_chain, method, :callbacks end base.send :include, ActiveSupport::Callbacks base.define_callbacks *CALLBACKS end |
Instance Method Details
#destroy_with_callbacks ⇒ Object
:nodoc:
18 19 20 21 22 23 |
# File 'lib/authgasm/session/callbacks.rb', line 18 def destroy_with_callbacks # :nodoc: run_callbacks(:before_destroy) result = destroy_without_callbacks run_callbacks(:after_destroy) if result result end |
#save_with_callbacks ⇒ Object
:nodoc:
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/authgasm/session/callbacks.rb', line 25 def save_with_callbacks # :nodoc: if new_session? run_callbacks(:before_create) else run_callbacks(:before_update) end run_callbacks(:before_save) result = save_without_callbacks if result if new_session? run_callbacks(:after_create) else run_callbacks(:after_update) end run_callbacks(:after_save) end result end |
#valid_with_callbacks? ⇒ Boolean
44 45 46 47 48 |
# File 'lib/authgasm/session/callbacks.rb', line 44 def valid_with_callbacks? result = valid_without_callbacks? run_callbacks(:after_validation) if result result end |
#validate_credentials_with_callbacks ⇒ Object
:nodoc:
50 51 52 53 |
# File 'lib/authgasm/session/callbacks.rb', line 50 def validate_credentials_with_callbacks # :nodoc: run_callbacks(:before_validation) validate_credentials_without_callbacks end |