Browse Source

Add some hated code comments to explain some things

pull/45/head
baarkerlounger 4 years ago
parent
commit
94e5a78eda
  1. 5
      app/models/case_log.rb

5
app/models/case_log.rb

@ -10,10 +10,15 @@ class CaseLogValidator < ActiveModel::Validator
end
def validate(record)
# If we've come from the form UI we only want to validate the specific fields
# that have just been submitted. If we're submitting a log via API or Bulk Upload
# we want to validate all data fields.
question_to_validate = options[:previous_page]
if question_to_validate && respond_to?("validate_#{question_to_validate}")
public_send("validate_#{question_to_validate}", record)
else
# This assumes that all methods in this class other than this one are
# validations to be run
validation_methods = public_methods(false) - [__callee__]
validation_methods.each { |meth| public_send(meth, record) }
end

Loading…
Cancel
Save