lib/fx.rb in fx-0.5.0 vs lib/fx.rb in fx-0.6.0
- old
+ new
@@ -5,13 +5,35 @@
require "fx/definition"
require "fx/function"
require "fx/statements"
require "fx/schema_dumper"
require "fx/trigger"
+require "fx/railtie"
# F(x) adds methods `ActiveRecord::Migration` to create and manage database
# triggers and functions in Rails applications.
module Fx
+ # Hooks Fx into Rails.
+ #
+ # Enables fx migration methods, migration reversability, and `schema.rb`
+ # dumping.
+ def self.load
+ ActiveRecord::Migration::CommandRecorder.send(
+ :include,
+ Fx::CommandRecorder,
+ )
+
+ ActiveRecord::SchemaDumper.send(
+ :prepend,
+ Fx::SchemaDumper,
+ )
+
+ ActiveRecord::ConnectionAdapters::AbstractAdapter.send(
+ :include,
+ Fx::Statements,
+ )
+ end
+
# The current database adapter used by F(x).
#
# This defaults to {Fx::Adapters::Postgres} but can be overridden
# via {Configuration}.
def self.database