Sha256: a7b44455ad6ecb82df1c23141f1a573f638b533fc9ee8c263e1ac31311da5243

Contents?: true

Size: 710 Bytes

Versions: 3

Compression:

Stored size: 710 Bytes

Contents

# frozen_string_literal: true

require 'adaptive_alias/patches/base'

module AdaptiveAlias
  module Patches
    class BackwardPatch < Base
      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

      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
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
adaptive_alias-1.3.0 lib/adaptive_alias/patches/backward_patch.rb
adaptive_alias-1.2.1 lib/adaptive_alias/patches/backward_patch.rb
adaptive_alias-1.2.0 lib/adaptive_alias/patches/backward_patch.rb