Module: ActiveRecord::PGEnum::CommandRecorder
- Defined in:
- lib/active_record/pg_enum/command_recorder.rb
Overview
ActiveRecord::Migration::CommandRecorder is a class used by reversible migrations. It captures the forward migration commands and translates them into their inverse by way of some simple metaprogramming.
The Migrator class uses CommandRecorder during the reverse migration instead of the connection object. Forward migration calls are translated to their inverse where possible, and then forwarded to the connetion. Irreversible migrations raise an exception.
Known schema statement methods are metaprogrammed into an inverse method like so:
create_table => invert_create_table
which returns:
[:drop_table, args.first]
Instance Method Summary collapse
- #add_enum_value(*args, &block) ⇒ Object
- #create_enum(*args, &block) ⇒ Object
- #drop_enum(*args, &block) ⇒ Object
Instance Method Details
#add_enum_value(*args, &block) ⇒ Object
28 29 30 |
# File 'lib/active_record/pg_enum/command_recorder.rb', line 28 def add_enum_value(*args, &block) record(:add_enum_value, args, &block) end |
#create_enum(*args, &block) ⇒ Object
20 21 22 |
# File 'lib/active_record/pg_enum/command_recorder.rb', line 20 def create_enum(*args, &block) record(:create_enum, args, &block) end |
#drop_enum(*args, &block) ⇒ Object
24 25 26 |
# File 'lib/active_record/pg_enum/command_recorder.rb', line 24 def drop_enum(*args, &block) record(:drop_enum, args, &block) end |