Module: Ripple::Callbacks
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/ripple/callbacks.rb
Overview
Adds lifecycle callbacks to Document models, in the typical ActiveModel fashion.
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- CALLBACK_TYPES =
[:create, :update, :save, :destroy, :validation]
Instance Method Summary collapse
- #destroy!(*args, &block) ⇒ Object
- #really_save(*args, &block) ⇒ Object
- #run_save_callbacks ⇒ Object
- #valid?(*args, &block) ⇒ Boolean
Instance Method Details
#destroy!(*args, &block) ⇒ Object
57 58 59 60 61 |
# File 'lib/ripple/callbacks.rb', line 57 def destroy!(*args, &block) run_callbacks(:destroy) do super end end |
#really_save(*args, &block) ⇒ Object
41 42 43 44 45 |
# File 'lib/ripple/callbacks.rb', line 41 def really_save(*args, &block) run_save_callbacks do super end end |
#run_save_callbacks ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/ripple/callbacks.rb', line 47 def run_save_callbacks state = new? ? :create : :update run_callbacks(:save) do run_callbacks(state) do yield end end end |
#valid?(*args, &block) ⇒ Boolean
64 65 66 67 68 69 |
# File 'lib/ripple/callbacks.rb', line 64 def valid?(*args, &block) @_on_validate = new? ? :create : :update run_callbacks(:validation) do super end end |