Sha256: 70de336c1e3ea4dfa6a7ebba2cd96abb24430ecc1f31466459834ebcdad7e3c5

Contents?: true

Size: 861 Bytes

Versions: 5

Compression:

Stored size: 861 Bytes

Contents

# frozen_string_literal: true

# :nodoc:
#
module ActiveRecord
  # :nodoc:
  #
  module ConnectionAdapters
    # :nodoc:
    #
    module PostgreSQL
      # :nodoc:
      #
      module ColumnMethods
        # Create an enum column with the provided name.
        #
        # By default, the enum type will match the name of the column.
        # You can change this behaviour by providing the enum type as an option under the `:enum_type` key.
        #
        # @example Creating a user role.
        #   t.enum :role, enum_type: :user_role
        #
        # @param enum_type [String] The name of the enum column.
        # @param options   [Hash]   The options (including the enum type).
        #
        def enum(name, options = {})
          column(name, options[:enum_type] || name, options.except(:enum_type))
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
enum_kit-0.3.1 lib/enum_kit/active_record_patches/connection_adapters/postgresql/column_methods.rb
enum_kit-0.3.0 lib/enum_kit/active_record_patches/connection_adapters/postgresql/column_methods.rb
enum_kit-0.2.3 lib/enum_kit/active_record_patches/connection_adapters/postgresql/column_methods.rb
enum_kit-0.2.2 lib/enum_kit/active_record_patches/connection_adapters/postgresql/column_methods.rb
enum_kit-0.2.1 lib/enum_kit/active_record_patches/connection_adapters/postgresql/column_methods.rb