Class: AdaptiveAlias::Patches::BackwardPatch

Inherits:
Base
  • Object
show all
Defined in:
lib/adaptive_alias/patches/backward_patch.rb

Instance Attribute Summary

Attributes inherited from Base

#check_matched, #removable, #remove_and_fix_association, #removed

Instance Method Summary collapse

Methods inherited from Base

#add_hooks!, #initialize, #log_warning, #mark_removable, #remove!

Constructor Details

This class inherits a constructor from AdaptiveAlias::Patches::Base

Instance Method Details

#apply!Object



8
9
10
11
12
# File 'lib/adaptive_alias/patches/backward_patch.rb', line 8

def apply!
  AdaptiveAlias.current_patches[[@klass, @old_column, @new_column]] = self
  @klass.alias_attribute(@old_column, @new_column)
  add_hooks!(current_column: @new_column, alias_column: @old_column, log_warning: true)
end

#do_remove!Object



14
15
16
17
18
19
20
21
# File 'lib/adaptive_alias/patches/backward_patch.rb', line 14

def do_remove!
  super
  @klass.remove_alias_attribute(@old_column)
  @klass.define_attribute_method(@old_column)
  new_patch = ForwardPatch.new(@klass, @old_column, @new_column)
  new_patch.apply!
  return new_patch
end