Sha256: be3e1a0f56a9444521e16e96419c21a43ff4c4fa2156477ee826207747e49bc9

Contents?: true

Size: 838 Bytes

Versions: 1

Compression:

Stored size: 838 Bytes

Contents

# frozen_string_literal: true

# :nodoc:
#
module EnumKit
  # :nodoc:
  #
  module ActiveRecordExtensions
    # :nodoc:
    #
    module Migration
      # :nodoc:
      #
      module CommandRecorder
        # :nodoc:
        #
        def create_enum(*args)
          record(:create_enum, args)
        end

        # :nodoc:
        #
        def drop_enum(*args)
          record(:drop_enum, args)
        end

        # :nodoc:
        #
        def invert_create_enum(args)
          record(:drop_enum, args.first)
        end

        # :nodoc:
        #
        def invert_drop_enum(args)
          unless args.length > 1
            raise ::ActiveRecord::IrreversibleMigration, 'drop_enum is only reversible if given an Array of values.'
          end

          record(:create_enum, args)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
enum_kit-0.1.0 lib/enum_kit/active_record_extensions/migration/command_recorder.rb