Sha256: 35acc841a771100cff47a5490960449af23ae8e227dd560ff33cd2f952160d1c

Contents?: true

Size: 725 Bytes

Versions: 2

Compression:

Stored size: 725 Bytes

Contents

module StrongMigrations
  module SchemaDumper
    def initialize(connection, ...)
      return super unless StrongMigrations.alphabetize_schema

      super(WrappedConnection.new(connection), ...)
    end
  end

  class WrappedConnection
    delegate_missing_to :@connection

    def initialize(connection)
      @connection = connection
    end

    def columns(...)
      @connection.columns(...).sort_by(&:name)
    end

    # forward private methods with send
    # method_missing cannot tell how method was called
    # this is not ideal, but other solutions have drawbacks
    def send(name, ...)
      if respond_to?(name, true)
        super
      else
        @connection.send(name, ...)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
strong_migrations-2.1.0 lib/strong_migrations/schema_dumper.rb
strong_migrations-2.0.2 lib/strong_migrations/schema_dumper.rb