Sha256: 0e88b02ad91a8a93e98c3e16fcbac2cc71d4a3d105b35f4ed3f1eeb5831cc2bf

Contents?: true

Size: 707 Bytes

Versions: 9

Compression:

Stored size: 707 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)
        @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

9 entries across 9 versions & 1 rubygems

Version Path
adaptive_alias-1.1.2 lib/adaptive_alias/patches/backward_patch.rb
adaptive_alias-1.1.1 lib/adaptive_alias/patches/backward_patch.rb
adaptive_alias-1.1.0 lib/adaptive_alias/patches/backward_patch.rb
adaptive_alias-1.0.0 lib/adaptive_alias/patches/backward_patch.rb
adaptive_alias-0.2.4 lib/adaptive_alias/patches/backward_patch.rb
adaptive_alias-0.2.3 lib/adaptive_alias/patches/backward_patch.rb
adaptive_alias-0.2.2 lib/adaptive_alias/patches/backward_patch.rb
adaptive_alias-0.2.1 lib/adaptive_alias/patches/backward_patch.rb
adaptive_alias-0.2.0 lib/adaptive_alias/patches/backward_patch.rb