Module: Card::Director::Phases
- Included in:
- Card::Director
- Defined in:
- lib/card/director/phases.rb
Overview
Validation, Storage, and Integration phase handling
Instance Method Summary collapse
- #integration_phase ⇒ Object
- #integration_phase_callback? ⇒ Boolean
- #prepare_for_phases ⇒ Object
-
#storage_phase(&block) ⇒ Object
Unlike other phases, the storage phase takes a block, because it is called by an “around” callback.
- #validation_phase ⇒ Object
- #validation_phase_callback? ⇒ Boolean
Instance Method Details
#integration_phase ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/card/director/phases.rb', line 42 def integration_phase return if @abort @card.restore_changes_information run_stage :integrate run_stage :after_integrate run_stage :integrate_with_delay ensure @card.clear_changes_information unless @abort end |
#integration_phase_callback? ⇒ Boolean
13 14 15 |
# File 'lib/card/director/phases.rb', line 13 def integration_phase_callback? !@only_storage_phase && main? end |
#prepare_for_phases ⇒ Object
17 18 19 20 21 |
# File 'lib/card/director/phases.rb', line 17 def prepare_for_phases @card.prepare_for_phases unless running? @running = true @subdirectors.each(&:prepare_for_phases) end |
#storage_phase(&block) ⇒ Object
Unlike other phases, the storage phase takes a block, because it is called by an “around” callback
33 34 35 36 37 38 39 40 |
# File 'lib/card/director/phases.rb', line 33 def storage_phase &block catch_up_to_stage :prepare_to_store run_stage :store, &block run_stage :finalize raise ActiveRecord::RecordInvalid, @card if @card.errors.any? ensure @from_trash = nil end |
#validation_phase ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/card/director/phases.rb', line 23 def validation_phase run_stage :initialize run_stage :prepare_to_validate run_stage :validate ensure @card.errors.empty? end |
#validation_phase_callback? ⇒ Boolean
9 10 11 |
# File 'lib/card/director/phases.rb', line 9 def validation_phase_callback? !@only_storage_phase && head? end |