Sha256: 24fedaaf13ee451116cb7274a814aa159881a85d9948a4473e8525c86b08766c

Contents?: true

Size: 576 Bytes

Versions: 1

Compression:

Stored size: 576 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 remove!
        super
        @klass.remove_alias_attribute(@old_column)
        ForwardPatch.new(@klass, @old_column, @new_column).apply!
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
adaptive_alias-0.0.2 lib/adaptive_alias/patches/backward_patch.rb