module Golden::EnumValueConcern

Public Instance Methods

enum_options_for_select(attribute_name) click to toggle source
# File lib/golden/active_record_concerns/enum_value_concern.rb, line 14
def enum_options_for_select(attribute_name)
  enums = send(attribute_name.to_s.pluralize)
  enums.values.uniq.map do |value|
    key = enums.key(value)
    [human_attribute_enum_value(attribute_name, key), key]
  end.to_h
end
human_attribute_enum(attribute_name) click to toggle source
# File lib/golden/active_record_concerns/enum_value_concern.rb, line 23
def human_attribute_enum(attribute_name)
  self.class.human_attribute_enum_value(attribute_name, send(attribute_name))
end
human_attribute_enum_value(attribute_name, value) click to toggle source
# File lib/golden/active_record_concerns/enum_value_concern.rb, line 8
def human_attribute_enum_value(attribute_name, value)
  return if value.blank?

  human_attribute_name("#{attribute_name}.#{value}")
end