Sha256: 3c908df2f77b000a34dcafb9da8ee836fa0fbb8a37e36d67e98ded0932e1d56d

Contents?: true

Size: 964 Bytes

Versions: 3

Compression:

Stored size: 964 Bytes

Contents

module Renalware
  module AttributeNameHelper
    # disables :reek:FeatureEnvy
    def attr_name(model, attr, suffix: nil)
      klass = model.is_a?(Class) ? model : model.class
      klass.human_attribute_name(attr) + String(suffix)
    end
  end

  # A WIP experiment to create a better way of generating attribute names from I18n
  # using the underlying human_attribute_name.
  # Not convinced yet this is worth added complexity but the idea to access labels eg for
  # table headers like so:
  #   PatientLabels.name
  #   PatientLabels.nhs_number
  #
  # class PatientLabels
  #   class << self
  #     # disables :reek:BooleanParameter
  #     def method_missing(method, *_args, &block)
  #       Renalware::Patient.human_attribute_name(method.to_sym) || super
  #     end

  #     def respond_to_missing?(_method_name, _include_private = false)
  #       true
  #     end

  #     def name
  #       method_missing(:name)
  #     end
  #   end
  # end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
renalware-core-2.0.0.pre.rc3 app/helpers/renalware/attribute_name_helper.rb
renalware-core-2.0.0.pre.rc1 app/helpers/renalware/attribute_name_helper.rb
renalware-core-2.0.0.pre.beta12 app/helpers/renalware/attribute_name_helper.rb