module ActiveRecord::EnumTranslation::ClassMethods

Public Instance Methods

human_enum_name_reader_for(enum_name) click to toggle source

Defines handy reader method for enum translation. @param [Symbol] enum_name @param [Hash] options @example

class User < ApplicationRecord
  human_enum_name_reader_for :status
end

User.new(status: :active).human_enum_name_for_status #=> "Active"
# File lib/activerecord/enum_translation.rb, line 50
def human_enum_name_reader_for(enum_name)
  define_method("human_enum_name_for_#{enum_name}") do |**options|
    human_enum_name_for(enum_name, **options)
  end
end