class Fx::Adapters::Postgres::Triggers

Fetches defined triggers from the postgres connection. @api private

Constants

TRIGGERS_WITH_DEFINITIONS_QUERY

The SQL query used by F(x) to retrieve the triggers considered dumpable into `db/schema.rb`.

Attributes

connection[R]

Public Class Methods

all(*args) click to toggle source

Wraps all as a static facade.

@return [Array<Fx::Trigger>]

# File lib/fx/adapters/postgres/triggers.rb, line 28
def self.all(*args)
  new(*args).all
end
new(connection) click to toggle source
# File lib/fx/adapters/postgres/triggers.rb, line 32
def initialize(connection)
  @connection = connection
end

Public Instance Methods

all() click to toggle source

All of the triggers that this connection has defined.

@return [Array<Fx::Trigger>]

# File lib/fx/adapters/postgres/triggers.rb, line 39
def all
  triggers_from_postgres.map { |trigger| to_fx_trigger(trigger) }
end

Private Instance Methods

to_fx_trigger(result) click to toggle source
# File lib/fx/adapters/postgres/triggers.rb, line 51
def to_fx_trigger(result)
  Fx::Trigger.new(result)
end
triggers_from_postgres() click to toggle source
# File lib/fx/adapters/postgres/triggers.rb, line 47
def triggers_from_postgres
  connection.execute(TRIGGERS_WITH_DEFINITIONS_QUERY)
end