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/adapters/postgres/triggers.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:



30
31
32
# File 'lib/fx.rb', line 30

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

.configuration=(config) ⇒ Object

Set F(x)'s configuration

Parameters:



37
38
39
# File 'lib/fx.rb', line 37

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:



50
51
52
# File 'lib/fx.rb', line 50

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.



58
59
60
# File 'lib/fx.rb', line 58

def self.database
  configuration.database
end

.loadObject

Hooks Fx into Rails.

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



21
22
23
24
25
26
27
# File 'lib/fx.rb', line 21

def self.load
  ActiveRecord::Migration::CommandRecorder.include(Fx::CommandRecorder)
  ActiveRecord::ConnectionAdapters::AbstractAdapter.include(Fx::Statements)
  ActiveRecord::SchemaDumper.prepend(Fx::SchemaDumper)

  true
end