Class: Renalware::Pathology::MeasurementUnit

Inherits:
ApplicationRecord show all
Defined in:
app/models/renalware/pathology/measurement_unit.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.for_collection_selectObject



12
13
14
# File 'app/models/renalware/pathology/measurement_unit.rb', line 12

def self.for_collection_select
  order(:name).select(:id, :name, :description).map { |row| [row.title, row.id] }
end

Instance Method Details

#titleObject

A friendly string containing name and description (if present) in parentheses e.g. “l (litres)”



18
19
20
21
22
# File 'app/models/renalware/pathology/measurement_unit.rb', line 18

def title
  return name if description.blank? || name == description

  "#{name} (#{description})"
end