Sha256: beb7ee5dd43d2043c5ff0c138f24699ca371ba613ec0870cc0f9125ddc77604c

Contents?: true

Size: 688 Bytes

Versions: 9

Compression:

Stored size: 688 Bytes

Contents

# frozen_string_literal: true

require 'adaptive_alias/patches/base'

module AdaptiveAlias
  module Patches
    class ForwardPatch < Base
      def apply!
        AdaptiveAlias.current_patches[[@klass, @old_column, @new_column]] = self
        @klass.alias_attribute(@new_column, @old_column)
        add_hooks!(current_column: @old_column, alias_column: @new_column)
      end

      def remove!
        super
        @klass.remove_alias_attribute(@new_column)
        @klass.define_attribute_method(@new_column)
        new_patch = BackwardPatch.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/forward_patch.rb
adaptive_alias-1.1.1 lib/adaptive_alias/patches/forward_patch.rb
adaptive_alias-1.1.0 lib/adaptive_alias/patches/forward_patch.rb
adaptive_alias-1.0.0 lib/adaptive_alias/patches/forward_patch.rb
adaptive_alias-0.2.4 lib/adaptive_alias/patches/forward_patch.rb
adaptive_alias-0.2.3 lib/adaptive_alias/patches/forward_patch.rb
adaptive_alias-0.2.2 lib/adaptive_alias/patches/forward_patch.rb
adaptive_alias-0.2.1 lib/adaptive_alias/patches/forward_patch.rb
adaptive_alias-0.2.0 lib/adaptive_alias/patches/forward_patch.rb