Sha256: e82d417b86ad2827f93ef96723ea5310ae9102cdfe9d98dbfea09636106e8097

Contents?: true

Size: 693 Bytes

Versions: 4

Compression:

Stored size: 693 Bytes

Contents

# frozen_string_literal: true

module Goldiloader
  module AssociationOptions
    extend self

    OPTIONS = [:fully_load].freeze

    # This is only used in Rails 5+
    module AssociationBuilderExtension
      def self.build(model, reflection)
        # We have no callbacks to register
      end

      def self.valid_options
        OPTIONS
      end
    end

    def register
      if Goldiloader::Compatibility.rails_4?
        ActiveRecord::Associations::Builder::Association.valid_options.concat(OPTIONS)
      else
        ActiveRecord::Associations::Builder::Association.extensions << AssociationBuilderExtension
      end
    end
  end
end

Goldiloader::AssociationOptions.register

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
goldiloader-3.2.0 lib/goldiloader/association_options.rb
goldiloader-3.1.1 lib/goldiloader/association_options.rb
goldiloader-3.1.0 lib/goldiloader/association_options.rb
goldiloader-3.0.3 lib/goldiloader/association_options.rb