Sha256: 62947213e36dd08970ac47aecd4f8c3209dd822f804b238612cf5760f0ed604c
Contents?: true
Size: 1.58 KB
Versions: 2
Compression:
Stored size: 1.58 KB
Contents
module Authgasm module Session # = Callbacks # # Just like in ActiveRecord you have before_save, before_validation, etc. You have similar callbacks with Authgasm, see all callbacks below. module Callbacks CALLBACKS = %w(before_create after_create before_destroy after_destroy before_save after_save before_update after_update before_validation after_validation) def self.included(base) #:nodoc: [:destroy, :save, :valid?].each do |method| base.send :alias_method_chain, method, :callbacks end base.send :include, ActiveSupport::Callbacks base.define_callbacks *CALLBACKS end def destroy_with_callbacks # :nodoc: run_callbacks(:before_destroy) result = destroy_without_callbacks run_callbacks(:after_destroy) if result result end 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 def valid_with_callbacks? # :nodoc: run_callbacks(:before_validation) result = valid_without_callbacks? if result run_callbacks(:after_validation) result = errors.empty? end result end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
authgasm-0.10.0 | lib/authgasm/session/callbacks.rb |
authgasm-0.10.1 | lib/authgasm/session/callbacks.rb |