module Card::Director::Phases
Validation, Storage, and Integration phase handling
Public Instance Methods
integration_phase()
click to toggle source
# File lib/card/director/phases.rb, line 44 def integration_phase # puts "integration phase: #{@card.name}" 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 @card.expire unless Cardio.delaying? # if delaying, then expired by clear end
integration_phase_callback?()
click to toggle source
# File lib/card/director/phases.rb, line 13 def integration_phase_callback? !@abort && !@only_storage_phase && main? end
prepare_for_phases()
click to toggle source
# File lib/card/director/phases.rb, line 17 def prepare_for_phases @card.prepare_for_phases unless running? @card.identify_action @running = true @subdirectors.each(&:prepare_for_phases) end
storage_phase(&block)
click to toggle source
Unlike other phases, the storage phase takes a block, because it is called by an “around” callback
# File lib/card/director/phases.rb, line 34 def storage_phase &block catch_up_to_stage :prepare_to_store # unless @abort # puts "before store #{@card.name}: abort:#{@abort}" run_stage :store, &block # unless @abort run_stage :finalize # unless @abort raise ActiveRecord::RecordInvalid, @card if @card.errors.any? ensure @from_trash = nil end
validation_phase()
click to toggle source
# File lib/card/director/phases.rb, line 24 def validation_phase run_stage :initialize run_stage :prepare_to_validate run_stage :validate ensure @card.errors.empty? end
validation_phase_callback?()
click to toggle source
# File lib/card/director/phases.rb, line 9 def validation_phase_callback? !@only_storage_phase && head? end