Sha256: 9b7a54ab4d7af6025df1d6bd5fe364083e0aa5493a2ea9907de38f45a108ba37

Contents?: true

Size: 1023 Bytes

Versions: 1

Compression:

Stored size: 1023 Bytes

Contents

# frozen_string_literal: true

require 'activemodel/associations'
require 'eac_rails_utils/patches/rails_4'
require 'eac_rails_utils/patches/rails_5_2'

module ActiveModel
  module Associations
    module Hooks
      class << self
        def init
          init_rails_4 if ::EacRailsUtils::Patches::Rails4.enabled?
          init_rails_5_2 if ::EacRailsUtils::Patches::Rails52.enabled?
        end

        def init_rails_4
          ActiveSupport.on_load(:active_record) do
            ActiveRecord::Associations::AssociationScope.prepend(
              ::EacRailsUtils::Patches::Rails4.ActiveRecordAssociationsAssociationScope
            )
          end
        end

        def init_rails_5_2
          rails_5_2_fix_activemodel_associations_methods
        end

        def rails_5_2_fix_activemodel_associations_methods
          %i[belongs_to has_many].each do |method|
            ::EacRailsUtils::Patches::Rails52::ActiveModelAssociationMethodFix.new(method)
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eac_rails_utils-0.13.4 lib/eac_rails_utils/patches/active_model_associations.rb