Sha256: 44a860e8285dee24af9346471430d0fe7be6aef9f1e7cde8095874ff614874ff

Contents?: true

Size: 462 Bytes

Versions: 2

Compression:

Stored size: 462 Bytes

Contents

# frozen_string_literal: true

# :nodoc:
#
module ActiveRecord
  # :nodoc:
  #
  module Enum
    # :nodoc:
    #
    class EnumType < Type::Value
      # :nodoc:
      #
      def assert_valid_value(value)
        return value if value.blank? || mapping.key?(value) || mapping.value?(value)
        return value if Rails.application.config.enum_kit.disable_exceptions

        raise ArgumentError, "'#{value}' is not a valid #{name}"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
enum_kit-0.3.1 lib/enum_kit/active_record_patches/enum/enum_type.rb
enum_kit-0.3.0 lib/enum_kit/active_record_patches/enum/enum_type.rb