jclem/active_record_rollout

View on GitHub
app/models/detour/concerns/custom_human_attributes.rb

Summary

Maintainability
A
0 mins
Test Coverage
module Detour::Concerns
  module CustomHumanAttributes
    extend ActiveSupport::Concern

    included do
      @human_attribute_names = {}

      class << self
        alias :original_human_attribute_name :human_attribute_name
      end

      def self.human_attribute_name(*args)
        @human_attribute_names[args[0]] || original_human_attribute_name(*args)
      end

      def self.set_human_attribute_name(key, name)
        @human_attribute_names[key] = name
      end
    end
  end
end