Class: Renalware::Transplants::CreateDonorStage

Inherits:
Object
  • Object
show all
Defined in:
app/models/renalware/transplants/create_donor_stage.rb

Instance Method Summary collapse

Constructor Details

#initialize(patient:, options: {}) ⇒ CreateDonorStage

Returns a new instance of CreateDonorStage.



12
13
14
15
# File 'app/models/renalware/transplants/create_donor_stage.rb', line 12

def initialize(patient:, options: {})
  @patient = patient
  @options = options
end

Instance Method Details

#callObject



17
18
19
20
21
22
23
24
25
26
27
# File 'app/models/renalware/transplants/create_donor_stage.rb', line 17

def call
  DonorStage.transaction do
    terminate_current_stage if current_stage.present?
    stage = build_new_stage
    if stage.save
      ::Success.new(stage)
    else
      ::Failure.new(stage)
    end
  end
end