Module: EnumKit::ActiveRecordExtensions::Migration::CommandRecorder
- Defined in:
- lib/enum_kit/active_record_extensions/migration/command_recorder.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#add_enum_value(*args) ⇒ Object
Record the addition of a value to an enum type.
-
#create_enum(*args) ⇒ Object
Record the creation of an enum type.
-
#drop_enum(*args) ⇒ Object
Record the deletion of an enum type.
-
#invert_add_enum_value(*args) ⇒ Object
Invert the addition of a value to an enum type by removing the value.
-
#invert_create_enum(*args) ⇒ Object
Invert the creation of an enum type by deleting it.
-
#invert_drop_enum(*args) ⇒ Object
Invert the deletion of an enum type by creating it.
-
#invert_rename_enum(*args) ⇒ Object
Invert the renaming of an enum by renaming it back to the previous name.
-
#invert_rename_enum_value(*args) ⇒ Object
Invert the renaming of an enum’s value by renaming it back to the previous value.
-
#rename_enum(*args) ⇒ Object
Record the renaming of an enum type.
-
#rename_enum_value(*args) ⇒ Object
Record the renaming of a value in an enum type.
Instance Method Details
#add_enum_value(*args) ⇒ Object
Record the addition of a value to an enum type.
35 36 37 |
# File 'lib/enum_kit/active_record_extensions/migration/command_recorder.rb', line 35 def add_enum_value(*args) record(:add_enum_value, args) end |
#create_enum(*args) ⇒ Object
Record the creation of an enum type.
17 18 19 |
# File 'lib/enum_kit/active_record_extensions/migration/command_recorder.rb', line 17 def create_enum(*args) record(:create_enum, args) end |
#drop_enum(*args) ⇒ Object
Record the deletion of an enum type.
29 30 31 |
# File 'lib/enum_kit/active_record_extensions/migration/command_recorder.rb', line 29 def drop_enum(*args) record(:drop_enum, args) end |
#invert_add_enum_value(*args) ⇒ Object
Invert the addition of a value to an enum type by removing the value.
72 73 74 |
# File 'lib/enum_kit/active_record_extensions/migration/command_recorder.rb', line 72 def invert_add_enum_value(*args) raise ActiveRecord::IrreversibleMigration, 'add_enum_value is not reversible.' end |
#invert_create_enum(*args) ⇒ Object
Invert the creation of an enum type by deleting it.
47 48 49 |
# File 'lib/enum_kit/active_record_extensions/migration/command_recorder.rb', line 47 def invert_create_enum(*args) record(:drop_enum, args.first) end |
#invert_drop_enum(*args) ⇒ Object
Invert the deletion of an enum type by creating it.
Note that ‘drop_enum` can only be reversed if given a collection of values to call `create_enum` with as the previously deleted enum values cannot be automatically determined.
62 63 64 65 66 67 68 |
# File 'lib/enum_kit/active_record_extensions/migration/command_recorder.rb', line 62 def invert_drop_enum(*args) unless args.length > 1 raise ActiveRecord::IrreversibleMigration, 'drop_enum is only reversible if given an Array of values.' end record(:create_enum, args) end |
#invert_rename_enum(*args) ⇒ Object
Invert the renaming of an enum by renaming it back to the previous name.
53 54 55 |
# File 'lib/enum_kit/active_record_extensions/migration/command_recorder.rb', line 53 def invert_rename_enum(*args) record(:rename_enum, args.reverse) end |
#invert_rename_enum_value(*args) ⇒ Object
Invert the renaming of an enum’s value by renaming it back to the previous value.
78 79 80 |
# File 'lib/enum_kit/active_record_extensions/migration/command_recorder.rb', line 78 def invert_rename_enum_value(*args) record(:rename_enum_value, args[0], args[2], args[1]) end |
#rename_enum(*args) ⇒ Object
Record the renaming of an enum type.
23 24 25 |
# File 'lib/enum_kit/active_record_extensions/migration/command_recorder.rb', line 23 def rename_enum(*args) record(:rename_enum, args) end |
#rename_enum_value(*args) ⇒ Object
Record the renaming of a value in an enum type.
41 42 43 |
# File 'lib/enum_kit/active_record_extensions/migration/command_recorder.rb', line 41 def rename_enum_value(*args) record(:rename_enum_value, args) end |