Browse Source

CLDC-4270: Add ? to boolean method

pull/3230/head
samyou-softwire 2 weeks ago
parent
commit
a859c104a5
  1. 4
      app/services/bulk_upload/lettings/year2025/csv_parser.rb
  2. 4
      app/services/bulk_upload/lettings/year2026/csv_parser.rb
  3. 4
      app/services/bulk_upload/sales/year2025/csv_parser.rb
  4. 4
      app/services/bulk_upload/sales/year2026/csv_parser.rb

4
app/services/bulk_upload/lettings/year2025/csv_parser.rb

@ -41,7 +41,7 @@ class BulkUpload::Lettings::Year2025::CsvParser
hash_rows = field_numbers hash_rows = field_numbers
.zip(stripped_row) .zip(stripped_row)
.map do |field, value| .map do |field, value|
field_is_valid = value_is_valid_for_field(field, value) field_is_valid = value_is_valid_for_field?(field, value)
correct_value = field_is_valid ? value : nil correct_value = field_is_valid ? value : nil
@ -133,7 +133,7 @@ private
# this is needed as a string passed to an int attribute is by default mapped to '0'. # this is needed as a string passed to an int attribute is by default mapped to '0'.
# this is bad as some questions will accept a '0'. so you could enter something invalid and not be told about it # this is bad as some questions will accept a '0'. so you could enter something invalid and not be told about it
def value_is_valid_for_field(field, value) def value_is_valid_for_field?(field, value)
field_type = ROW_PARSER_CLASS.attribute_types[field] field_type = ROW_PARSER_CLASS.attribute_types[field]
if field_type.is_a?(ActiveModel::Type::Integer) if field_type.is_a?(ActiveModel::Type::Integer)

4
app/services/bulk_upload/lettings/year2026/csv_parser.rb

@ -40,7 +40,7 @@ class BulkUpload::Lettings::Year2026::CsvParser
hash_rows = field_numbers hash_rows = field_numbers
.zip(stripped_row) .zip(stripped_row)
.map do |field, value| .map do |field, value|
field_is_valid = value_is_valid_for_field(field, value) field_is_valid = value_is_valid_for_field?(field, value)
correct_value = field_is_valid ? value : nil correct_value = field_is_valid ? value : nil
@ -142,7 +142,7 @@ private
# this is needed as a string passed to an int attribute is by default mapped to '0'. # this is needed as a string passed to an int attribute is by default mapped to '0'.
# this is bad as some questions will accept a '0'. so you could enter something invalid and not be told about it # this is bad as some questions will accept a '0'. so you could enter something invalid and not be told about it
def value_is_valid_for_field(field, value) def value_is_valid_for_field?(field, value)
field_type = ROW_PARSER_CLASS.attribute_types[field] field_type = ROW_PARSER_CLASS.attribute_types[field]
if field_type.is_a?(ActiveModel::Type::Integer) if field_type.is_a?(ActiveModel::Type::Integer)

4
app/services/bulk_upload/sales/year2025/csv_parser.rb

@ -41,7 +41,7 @@ class BulkUpload::Sales::Year2025::CsvParser
hash_rows = field_numbers hash_rows = field_numbers
.zip(stripped_row) .zip(stripped_row)
.map do |field, value| .map do |field, value|
field_is_valid = value_is_valid_for_field(field, value) field_is_valid = value_is_valid_for_field?(field, value)
correct_value = field_is_valid ? value : nil correct_value = field_is_valid ? value : nil
@ -136,7 +136,7 @@ private
# this is needed as a string passed to an int attribute is by default mapped to '0'. # this is needed as a string passed to an int attribute is by default mapped to '0'.
# this is bad as some questions will accept a '0'. so you could enter something invalid and not be told about it # this is bad as some questions will accept a '0'. so you could enter something invalid and not be told about it
def value_is_valid_for_field(field, value) def value_is_valid_for_field?(field, value)
field_type = ROW_PARSER_CLASS.attribute_types[field] field_type = ROW_PARSER_CLASS.attribute_types[field]
if field_type.is_a?(ActiveModel::Type::Integer) if field_type.is_a?(ActiveModel::Type::Integer)

4
app/services/bulk_upload/sales/year2026/csv_parser.rb

@ -40,7 +40,7 @@ class BulkUpload::Sales::Year2026::CsvParser
hash_rows = field_numbers hash_rows = field_numbers
.zip(stripped_row) .zip(stripped_row)
.map do |field, value| .map do |field, value|
field_is_valid = value_is_valid_for_field(field, value) field_is_valid = value_is_valid_for_field?(field, value)
correct_value = field_is_valid ? value : nil correct_value = field_is_valid ? value : nil
@ -135,7 +135,7 @@ private
# this is needed as a string passed to an int attribute is by default mapped to '0'. # this is needed as a string passed to an int attribute is by default mapped to '0'.
# this is bad as some questions will accept a '0'. so you could enter something invalid and not be told about it # this is bad as some questions will accept a '0'. so you could enter something invalid and not be told about it
def value_is_valid_for_field(field, value) def value_is_valid_for_field?(field, value)
field_type = ROW_PARSER_CLASS.attribute_types[field] field_type = ROW_PARSER_CLASS.attribute_types[field]
if field_type.is_a?(ActiveModel::Type::Integer) if field_type.is_a?(ActiveModel::Type::Integer)

Loading…
Cancel
Save