Class: LocationReport::LocationReportForm
- Inherits:
-
Object
- Object
- LocationReport::LocationReportForm
- Includes:
- ActiveModel::AttributeMethods, ActiveModel::Model
- Defined in:
- app/models/location_report/location_report_form.rb
Overview
This form object class handles the user interaction for creating new Location Reports. It sensibility checks the user-entered list of barcode sequences or selection parameters before creating the Location Report model.
Instance Attribute Summary collapse
- #barcodes ⇒ Object
-
#barcodes_text ⇒ Object
Returns the value of attribute barcodes_text.
-
#end_date ⇒ Object
Attributes.
-
#faculty_sponsor_ids ⇒ Object
Attributes.
-
#location_barcode ⇒ Object
Returns the value of attribute location_barcode.
- #location_report ⇒ Object
-
#name ⇒ Object
Returns the value of attribute name.
-
#plate_purpose_ids ⇒ Object
Attributes.
-
#report_type ⇒ Object
Attributes.
-
#start_date ⇒ Object
Attributes.
-
#study_id ⇒ Object
Attributes.
-
#user ⇒ Object
Attributes.
Class Method Summary collapse
-
.model_name ⇒ Object
form builder methods (e.g. form_to) need the Active Model name to be set.
Instance Method Summary collapse
Instance Attribute Details
#barcodes ⇒ Object
60 61 62 |
# File 'app/models/location_report/location_report_form.rb', line 60 def @barcodes ||= &.squish&.split(/[\s,]+/) || [] end |
#barcodes_text ⇒ Object
Returns the value of attribute barcodes_text.
15 16 17 |
# File 'app/models/location_report/location_report_form.rb', line 15 def @barcodes_text end |
#end_date ⇒ Object
Attributes
13 14 15 |
# File 'app/models/location_report/location_report_form.rb', line 13 def end_date @end_date end |
#faculty_sponsor_ids ⇒ Object
Attributes
13 14 15 |
# File 'app/models/location_report/location_report_form.rb', line 13 def faculty_sponsor_ids @faculty_sponsor_ids end |
#location_barcode ⇒ Object
Returns the value of attribute location_barcode.
16 17 18 |
# File 'app/models/location_report/location_report_form.rb', line 16 def @location_barcode end |
#location_report ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/models/location_report/location_report_form.rb', line 34 def location_report @location_report || @location_report = LocationReport.new( user: user, name: name, report_type: report_type, location_barcode: , faculty_sponsor_ids: faculty_sponsor_ids, study_id: study_id, start_date: start_date&.to_datetime, end_date: end_date&.to_datetime, plate_purpose_ids: plate_purpose_ids, barcodes: ) end |
#name ⇒ Object
Returns the value of attribute name.
16 17 18 |
# File 'app/models/location_report/location_report_form.rb', line 16 def name @name end |
#plate_purpose_ids ⇒ Object
Attributes
13 14 15 |
# File 'app/models/location_report/location_report_form.rb', line 13 def plate_purpose_ids @plate_purpose_ids end |
#report_type ⇒ Object
Attributes
13 14 15 |
# File 'app/models/location_report/location_report_form.rb', line 13 def report_type @report_type end |
#start_date ⇒ Object
Attributes
13 14 15 |
# File 'app/models/location_report/location_report_form.rb', line 13 def start_date @start_date end |
#study_id ⇒ Object
Attributes
13 14 15 |
# File 'app/models/location_report/location_report_form.rb', line 13 def study_id @study_id end |
#user ⇒ Object
Attributes
13 14 15 |
# File 'app/models/location_report/location_report_form.rb', line 13 def user @user end |
Class Method Details
.model_name ⇒ Object
form builder methods (e.g. form_to) need the Active Model name to be set
56 57 58 |
# File 'app/models/location_report/location_report_form.rb', line 56 def self.model_name ActiveModel::Name.new(LocationReport) end |
Instance Method Details
#save ⇒ Object
51 52 53 |
# File 'app/models/location_report/location_report_form.rb', line 51 def save location_report.save if valid? end |