module MR::AfterCommit::RecordProcsMethods
Constants
- DEFAULT_CALLBACK_TYPE
- VALID_CALLBACK_TYPES
Public Instance Methods
add_after_commit_proc(callback_type = nil, &block)
click to toggle source
# File lib/mr/after_commit/record_procs_methods.rb, line 25 def add_after_commit_proc(callback_type = nil, &block) callback_type ||= DEFAULT_CALLBACK_TYPE mr_after_commit_procs_hash[callback_type.to_sym] << block end
after_commit_procs(*keys)
click to toggle source
these methods are used by the `Record` and `FakeRecord` mixins
# File lib/mr/after_commit/record_procs_methods.rb, line 17 def after_commit_procs(*keys) if keys.empty? mr_after_commit_procs_hash.values.flatten else keys.map{ |k| mr_after_commit_procs_hash[k.to_sym] }.flatten end end
called_after_commit_procs(*keys)
click to toggle source
# File lib/mr/after_commit/record_procs_methods.rb, line 43 def called_after_commit_procs(*keys) if keys.empty? mr_after_commit_called_procs_hash.values.flatten else keys.map{ |k| mr_after_commit_called_procs_hash[k.to_sym] }.flatten end end
clear_after_commit_procs(*keys)
click to toggle source
# File lib/mr/after_commit/record_procs_methods.rb, line 35 def clear_after_commit_procs(*keys) if keys.empty? mr_after_commit_procs_hash.clear else keys.map{ |k| mr_after_commit_procs_hash.delete(k.to_sym) } end end
prepend_after_commit_proc(callback_type = nil, &block)
click to toggle source
# File lib/mr/after_commit/record_procs_methods.rb, line 30 def prepend_after_commit_proc(callback_type = nil, &block) callback_type ||= DEFAULT_CALLBACK_TYPE mr_after_commit_procs_hash[callback_type.to_sym].unshift(block) end
Private Instance Methods
mr_after_commit_call_procs(callback_type)
click to toggle source
# File lib/mr/after_commit/record_procs_methods.rb, line 53 def mr_after_commit_call_procs(callback_type) procs = self.after_commit_procs(callback_type) procs.each(&:call) mr_after_commit_called_procs_hash[callback_type] += procs self.clear_after_commit_procs(callback_type) end
mr_after_commit_called_procs_hash()
click to toggle source
# File lib/mr/after_commit/record_procs_methods.rb, line 64 def mr_after_commit_called_procs_hash @mr_after_commit_called_procs_hash ||= MR::AfterCommit::CallbackProcsHash.new end
mr_after_commit_procs_hash()
click to toggle source
# File lib/mr/after_commit/record_procs_methods.rb, line 60 def mr_after_commit_procs_hash @mr_after_commit_procs_hash ||= MR::AfterCommit::CallbackProcsHash.new end