method

assert_valid_enum_definition_values

Importance_0
v7.0.0 - Show latest stable - 0 notes - Class: Enum
assert_valid_enum_definition_values(values) private

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File activerecord/lib/active_record/enum.rb, line 269
      def assert_valid_enum_definition_values(values)
        unless values.is_a?(Hash) || values.all?(Symbol) || values.all?(String)
          error_message = <<~MSG
            Enum values #{values} must be either a hash, an array of symbols, or an array of strings.
          MSG
          raise ArgumentError, error_message
        end

        if values.is_a?(Hash) && values.keys.any?(&:blank?) || values.is_a?(Array) && values.any?(&:blank?)
          raise ArgumentError, "Enum label name must not be blank."
        end
      end
Register or log in to add new notes.