Module: CafeCar::NamePatch

Defined in:
lib/cafe_car/name_patch.rb

Class Method Summary collapse

Class Method Details

.patch!Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/cafe_car/name_patch.rb', line 3

def self.patch!
  ActiveModel::Name.class_eval do
    def human(options = {})
      return @human if i18n_keys.empty? || i18n_scope.empty?

      key, *defaults = i18n_keys
      defaults << options[:default] if options[:default]
      defaults << @human

      I18n.translate(key, scope: i18n_scope, count: 1, **options, default: defaults)
    end
  end
end