class PGTrunk::Adapters::Postgres

Creates an instance of the PGTrunk Postgres adapter. This is the only supported adapter for PGTrunk.

@param [#connection] connectable An object that returns the connection

for PGTrunk to use. Defaults to `ActiveRecord::Base`.

Attributes

connectable[R]

Public Instance Methods

dumper() click to toggle source
# File lib/pg_trunk/core/adapters/postgres.rb, line 53
def dumper
  # This instance is used to dump the table
  # using its name extracted from the database.
  # That's why we can skip prefix/suffix definitions
  # in the parameters of the constructor.
  @dumper ||= connection.create_schema_dumper({})
end
execute_operation(operation) click to toggle source

Execute operation by its definition @param [Class < PgExtra::Operation] operation

# File lib/pg_trunk/core/adapters/postgres.rb, line 48
def execute_operation(operation)
  query = operation.to_sql(server_version)
  connection.execute(query) if query
end

Private Instance Methods

connection() click to toggle source
# File lib/pg_trunk/core/adapters/postgres.rb, line 65
def connection
  @connection ||= Connection.new(ActiveRecord::Base.connection)
end
method_missing(symbol, *args, **opts, &block) click to toggle source
Calls superclass method
# File lib/pg_trunk/core/adapters/postgres.rb, line 73
def method_missing(symbol, *args, **opts, &block)
  super unless connection.respond_to?(symbol, true)

  connection.send(symbol, *args, **opts, &block)
end
respond_to_missing?(symbol, *) click to toggle source
# File lib/pg_trunk/core/adapters/postgres.rb, line 69
def respond_to_missing?(symbol, *)
  connection.respond_to?(symbol, true)
end