Module: Fx

Defined in:
lib/fx.rb,
lib/fx/railtie.rb,
lib/fx/trigger.rb,
lib/fx/version.rb,
lib/generators.rb,
lib/fx/function.rb,
lib/fx/definition.rb,
lib/fx/statements.rb,
lib/fx/configuration.rb,
lib/fx/schema_dumper.rb,
lib/fx/command_recorder.rb,
lib/fx/adapters/postgres.rb,
lib/fx/statements/trigger.rb,
lib/fx/statements/function.rb,
lib/fx/schema_dumper/trigger.rb,
lib/fx/schema_dumper/function.rb,
lib/fx/command_recorder/trigger.rb,
lib/fx/command_recorder/function.rb,
lib/fx/adapters/postgres/triggers.rb,
lib/fx/command_recorder/arguments.rb,
lib/fx/adapters/postgres/functions.rb,
lib/fx/adapters/postgres/connection.rb,
lib/generators/fx/trigger/trigger_generator.rb,
lib/generators/fx/function/function_generator.rb

Overview

F(x) adds methods ActiveRecord::Migration to create and manage database triggers and functions in Rails applications.

Defined Under Namespace

Modules: Adapters, Generators Classes: Configuration, Railtie

Class Method Summary collapse

Class Method Details

.configurationFx::Configuration

Returns F(x)'s current configuration.

Returns:



3
4
5
# File 'lib/fx/configuration.rb', line 3

def self.configuration
  @_configuration ||= Configuration.new
end

.configuration=(config) ⇒ Object

Set F(x)'s configuration

Parameters:



10
11
12
# File 'lib/fx/configuration.rb', line 10

def self.configuration=(config)
  @_configuration = config
end

.configure {|config| ... } ⇒ Object

Modify F(x)'s current configuration

Fx.configure do |config|
  config.database = Fx::Adapters::Postgres
  config.dump_functions_at_beginning_of_schema = true
end

Yield Parameters:



23
24
25
# File 'lib/fx/configuration.rb', line 23

def self.configure
  yield configuration
end

.databaseObject

The current database adapter used by F(x).

This defaults to Fx::Adapters::Postgres but can be overridden via Configuration.



40
41
42
# File 'lib/fx.rb', line 40

def self.database
  configuration.database
end

.loadObject

Hooks Fx into Rails.

Enables fx migration methods, migration reversability, and schema.rb dumping.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/fx.rb', line 19

def self.load
  ActiveRecord::Migration::CommandRecorder.send(
    :include,
    Fx::CommandRecorder,
  )

  ActiveRecord::SchemaDumper.send(
    :prepend,
    Fx::SchemaDumper,
  )

  ActiveRecord::ConnectionAdapters::AbstractAdapter.send(
    :include,
    Fx::Statements,
  )
end