Sha256: 52eaf666332188e2495a936482061e7e7e1b1633fe304647b07a126d4a370308

Contents?: true

Size: 648 Bytes

Versions: 7

Compression:

Stored size: 648 Bytes

Contents

module ActiveRecord
  module PGEnum
    register :table_definition do
      require "active_record/connection_adapters/postgresql_adapter"
      ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::TableDefinition.include TableDefinition
      ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::Table.include TableDefinition
    end

    module TableDefinition
      # Create an enum column inside a TableDefinition
      #
      # Example:
      #
      #   create_table :orders do |t|
      #     t.enum :status, as: "status_type"
      #   end
      def enum(name, as:, **options)
        column(name, as, options)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
activerecord-pg_enum-2.0.0 lib/active_record/pg_enum/4.1/table_definition.rb
activerecord-pg_enum-1.2.2 lib/active_record/pg_enum/4.1/table_definition.rb
activerecord-pg_enum-1.2.1 lib/active_record/pg_enum/4.1/table_definition.rb
activerecord-pg_enum-1.2.0 lib/active_record/pg_enum/4.1/table_definition.rb
activerecord-pg_enum-1.1.0 lib/active_record/pg_enum/4.1/table_definition.rb
activerecord-pg_enum-1.0.5 lib/active_record/pg_enum/4.1/table_definition.rb
activerecord-pg_enum-1.0.4 lib/active_record/pg_enum/4.1/table_definition.rb