Sha256: ccf9d34ead51b03f360d7cf8c12a7eeba7eba073c41107b5a93ca4d0dfd0107a

Contents?: true

Size: 749 Bytes

Versions: 15

Compression:

Stored size: 749 Bytes

Contents

# frozen_string_literal: true

require_dependency "renalware/pathology"

module Renalware
  module Pathology
    class MeasurementUnit < ApplicationRecord
      validates :name, presence: true
      has_many :observation_descriptions, inverse_of: :measurement_unit
      belongs_to :ukrdc_measurement_unit, class_name: "Renalware::UKRDC::MeasurementUnit"

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

      # A friendly string containing name and description (if present) in parentheses
      # e.g. "l (litres)"
      def title
        return name if description.blank? || name == description

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

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
renalware-core-2.1.1 app/models/renalware/pathology/measurement_unit.rb
renalware-core-2.1.0 app/models/renalware/pathology/measurement_unit.rb
renalware-core-2.0.167 app/models/renalware/pathology/measurement_unit.rb
renalware-core-2.0.166 app/models/renalware/pathology/measurement_unit.rb
renalware-core-2.0.165 app/models/renalware/pathology/measurement_unit.rb
renalware-core-2.0.164 app/models/renalware/pathology/measurement_unit.rb
renalware-core-2.0.163 app/models/renalware/pathology/measurement_unit.rb
renalware-core-2.0.162 app/models/renalware/pathology/measurement_unit.rb
renalware-core-2.0.161 app/models/renalware/pathology/measurement_unit.rb
renalware-core-2.0.160 app/models/renalware/pathology/measurement_unit.rb
renalware-core-2.0.159 app/models/renalware/pathology/measurement_unit.rb
renalware-core-2.0.158 app/models/renalware/pathology/measurement_unit.rb
renalware-core-2.0.157 app/models/renalware/pathology/measurement_unit.rb
renalware-core-2.0.156 app/models/renalware/pathology/measurement_unit.rb
renalware-core-2.0.155 app/models/renalware/pathology/measurement_unit.rb