Module: PGTrunk::CommandRecorder
- Defined in:
- lib/pg_trunk/core/railtie/command_recorder.rb
Overview
The module record commands done during a migration.
Class Method Summary collapse
Class Method Details
.register(klass) ⇒ Object
8 9 10 11 12 |
# File 'lib/pg_trunk/core/railtie/command_recorder.rb', line 8 def self.register(klass) define_method(klass.ruby_name) do |*args, &block| record(klass.ruby_name, args, &block) end end |
.register_inversion(klass) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/pg_trunk/core/railtie/command_recorder.rb', line 15 def self.register_inversion(klass) define_method(klass.ruby_iname) do |args, &block| original = klass.from_ruby(*args, &block) inverted = original.invert! # for example (skip_inversion(:validate_foreign_key)) return [:skip_inversion, [klass.ruby_name]] unless inverted # list of attributes `to_a` is added for reporting to stdout params = inverted.to_a opts = inverted.to_opts params << opts if opts.present? [inverted.class.ruby_name, params] end end |