Sha256: db1a6a0616b9b34733e72d83582e035284d499f7a9cc4ec03aeb8effae61d024

Contents?: true

Size: 917 Bytes

Versions: 14

Compression:

Stored size: 917 Bytes

Contents

# frozen_string_literal: true

require 'activemodel/associations'
require 'eac_ruby_utils/core_ext'

module EacRailsUtils
  module Patches
    module Rails52
      class ActiveModelAssociationMethodFix
        common_constructor :method_name do
          perform
        end

        def original_method_new_name
          "original_#{method_name}".to_sym
        end

        private

        def the_module
          ::ActiveModel::Associations::ClassMethods
        end

        def perform
          patch = self
          the_module.class_eval do
            alias_method patch.original_method_new_name, patch.method_name
            remove_method patch.method_name

            define_method patch.method_name do |name, scope = nil, **options, &extension|
              send(patch.original_method_new_name, name, scope, options, &extension)
            end
          end
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
eac_rails_utils-0.20.0 lib/eac_rails_utils/patches/rails_5_2/active_model_association_method_fix.rb
eac_rails_utils-0.19.0 lib/eac_rails_utils/patches/rails_5_2/active_model_association_method_fix.rb
eac_rails_utils-0.18.0 lib/eac_rails_utils/patches/rails_5_2/active_model_association_method_fix.rb
eac_rails_utils-0.17.2 lib/eac_rails_utils/patches/rails_5_2/active_model_association_method_fix.rb
eac_rails_utils-0.17.1 lib/eac_rails_utils/patches/rails_5_2/active_model_association_method_fix.rb
eac_rails_utils-0.17.0 lib/eac_rails_utils/patches/rails_5_2/active_model_association_method_fix.rb
eac_rails_utils-0.16.0 lib/eac_rails_utils/patches/rails_5_2/active_model_association_method_fix.rb
eac_rails_utils-0.15.2 lib/eac_rails_utils/patches/rails_5_2/active_model_association_method_fix.rb
eac_rails_utils-0.15.1 lib/eac_rails_utils/patches/rails_5_2/active_model_association_method_fix.rb
eac_rails_utils-0.15.0 lib/eac_rails_utils/patches/rails_5_2/active_model_association_method_fix.rb
eac_rails_utils-0.14.1 lib/eac_rails_utils/patches/rails_5_2/active_model_association_method_fix.rb
eac_rails_utils-0.14.0 lib/eac_rails_utils/patches/rails_5_2/active_model_association_method_fix.rb
eac_rails_utils-0.13.5 lib/eac_rails_utils/patches/rails_5_2/active_model_association_method_fix.rb
eac_rails_utils-0.13.4 lib/eac_rails_utils/patches/rails_5_2/active_model_association_method_fix.rb