Sha256: c651a614bab603b782804c66be83eec4e1d3a255137339e1f93a3c7a5d6d0cef
Contents?: true
Size: 1.33 KB
Versions: 2
Compression:
Stored size: 1.33 KB
Contents
module ActiveRecord class Migration # <tt>ActiveRecord::Migration::CommandRecorder</tt> records commands done during # a migration and knows how to reverse those commands. The CommandRecorder # knows how to invert the following commands: # # Adds... # * add_authorstamps # * remove_authorstamps class CommandRecorder [ # irreversible methods need to be here too :add_authorstamps, :remove_authorstamps, ].each do |method| class_eval <<-EOV, __FILE__, __LINE__ + 1 def #{method}(*args, &block) # def create_table(*args, &block) record(:"#{method}", args, &block) # record(:create_table, args, &block) end # end EOV end module StraightReversions private { add_authorstamps: :remove_authorstamps }.each do |cmd, inv| [[inv, cmd], [cmd, inv]].uniq.each do |method, inverse| class_eval <<-EOV, __FILE__, __LINE__ + 1 def invert_#{method}(args, &block) # def invert_create_table(args, &block) [:#{inverse}, args, block] # [:drop_table, args, block] end # end EOV end end end include StraightReversions end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ar-audit-tracer-2.0.1 | lib/active_record/migration/command_recorder.rb |
ar-audit-tracer-2.0.0 | lib/active_record/migration/command_recorder.rb |