Class: Renalware::PD::UnifiedPETAdequacyForm

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model, Virtus::Model
Defined in:
app/models/renalware/pd/unified_pet_adequacy_form.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.model_nameObject

This method lets us just use eg simple_form_for in the view without having to specify the url option i.e. PatientPDUnifiedPetAdequacy here will resolve to ‘patient_pd_pet_adequacy_results_path’



41
42
43
# File 'app/models/renalware/pd/unified_pet_adequacy_form.rb', line 41

def self.model_name
  ActiveModel::Name.new(self, nil, "PatientPDUnifiedPetAdequacy")
end

Instance Method Details

#objects_to_saveObject



29
30
31
32
33
34
35
36
# File 'app/models/renalware/pd/unified_pet_adequacy_form.rb', line 29

def objects_to_save
  @objects_to_save ||= begin
    [].tap do |arr|
      arr << pet unless pet_missing
      arr << adequacy unless adequacy_missing
    end
  end
end

#save_by!(user) ⇒ Object



23
24
25
26
27
# File 'app/models/renalware/pd/unified_pet_adequacy_form.rb', line 23

def save_by!(user)
  PETResult.transaction do
    objects_to_save.each { |obj| obj.save_by!(user) }
  end
end

#valid?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'app/models/renalware/pd/unified_pet_adequacy_form.rb', line 19

def valid?
  objects_to_save.each(&:validate).all?(&:valid?)
end