lib/types/validating_enum_type.rb
# Raise a KeyError if the value isn't a defined enum value during this conversion to a DB value
#
# @see https://github.com/rails/rails/blob/v5.2.6/activerecord/lib/active_record/enum.rb#L134-L136
Raise a KeyError if the value isn't a defined enum value during this conversion to a DB value
Raise a KeyError if the value isn ' t a defined enum value during this conversion to a DB value
def serialize(value)
    return if value.blank?
    case
    when mapping.key?(value)
      mapping[value]
    when mapping.value?(value)
      value
    else
      raise KeyError.new("unknown enum mapping: #{value.inspect}", key: value)
    end
  end
def serialize ( value ) return if value . blank? case when mapping . key? ( value ) mapping [ value ] when mapping . value? ( value ) value else raise KeyError . new ( "unknown enum mapping: #{value.inspect}" , key : value ) end end
Raise a KeyError if the value isn't a defined enum value during this conversion to a DB value
Raise a KeyError if the value isn ' t a defined enum value during this conversion to a DB value
value
<not_specific>
see
None