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
- #rename_enum(name, options = {}) ⇒ Object
- #rename_enum_value(type, options = {}) ⇒ Object
Instance Method Details
#add_enum_value(*args, &block) ⇒ Object
33 34 35 |
# File 'lib/active_record/pg_enum/command_recorder.rb', line 33 def add_enum_value(*args, &block) record(:add_enum_value, args, &block) end |
#create_enum(*args, &block) ⇒ Object
25 26 27 |
# File 'lib/active_record/pg_enum/command_recorder.rb', line 25 def create_enum(*args, &block) record(:create_enum, args, &block) end |
#drop_enum(*args, &block) ⇒ Object
29 30 31 |
# File 'lib/active_record/pg_enum/command_recorder.rb', line 29 def drop_enum(*args, &block) record(:drop_enum, args, &block) end |
#rename_enum(name, options = {}) ⇒ Object
37 38 39 |
# File 'lib/active_record/pg_enum/command_recorder.rb', line 37 def rename_enum(name, = {}) record(:rename_enum, [name, ]) end |
#rename_enum_value(type, options = {}) ⇒ Object
41 42 43 |
# File 'lib/active_record/pg_enum/command_recorder.rb', line 41 def rename_enum_value(type, = {}) record(:rename_enum_value, [type, ]) end |