Sha256: f121e3bb864a0f20dd208c3a1b17d3919253bca8026dd679424b246add9d2cfe

Contents?: true

Size: 918 Bytes

Versions: 8

Compression:

Stored size: 918 Bytes

Contents

module Renalware
  module Personable
    extend ActiveSupport::Concern

    included do
      class_eval do
        validates :family_name, presence: true
        validates :given_name,
                  presence: {
                    unless: -> {
                      defined?(skip_given_name_validation?) && skip_given_name_validation?
                    }
                  }
      end

      def full_name
        [given_name, family_name].compact.join(" ")
      end

      def to_s(format = :default)
        case format
        when :default
          [family_name, given_name].compact.join(", ")
        when :long
          "#{family_name}, #{given_name} (#{nhs_number})"
        end
      end

      def salutation
        parts = [Renalware.config.salutation_prefix]
        parts << (title.presence || given_name)
        parts << family_name
        parts.compact.join(" ")
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
renalware-core-2.0.0.pre.rc11 app/models/concerns/renalware/personable.rb
renalware-core-2.0.0.pre.rc10 app/models/concerns/renalware/personable.rb
renalware-core-2.0.0.pre.rc9 app/models/concerns/renalware/personable.rb
renalware-core-2.0.0.pre.rc8 app/models/concerns/renalware/personable.rb
renalware-core-2.0.0.pre.rc7 app/models/concerns/renalware/personable.rb
renalware-core-2.0.0.pre.rc6 app/models/concerns/renalware/personable.rb
renalware-core-2.0.0.pre.rc5 app/models/concerns/renalware/personable.rb
renalware-core-2.0.0.pre.rc4 app/models/concerns/renalware/personable.rb