Sha256: ca510a64b1fd989a6148dc1aa387715be25f47039c14578cddd185a0d51a9537

Contents?: true

Size: 777 Bytes

Versions: 1

Compression:

Stored size: 777 Bytes

Contents

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

      super(WrappedConnection.new(connection), *args, **options)
    end
  end

  class WrappedConnection
    delegate_missing_to :@connection

    def initialize(connection)
      @connection = connection
    end

    def columns(*args, **options)
      @connection.columns(*args, **options).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

1 entries across 1 versions & 1 rubygems

Version Path
strong_migrations-2.0.1 lib/strong_migrations/schema_dumper.rb