Sha256: faab865ab76072b5f326daab0171b539bdb8c4e8adee3a0e977f128a728b95c2

Contents?: true

Size: 693 Bytes

Versions: 3

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 ::ActiveRecord::VERSION::MAJOR >= 5
        ActiveRecord::Associations::Builder::Association.extensions << AssociationBuilderExtension
      else
        ActiveRecord::Associations::Builder::Association.valid_options.concat(OPTIONS)
      end
    end
  end
end

Goldiloader::AssociationOptions.register

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
goldiloader-3.0.2 lib/goldiloader/association_options.rb
goldiloader-3.0.1 lib/goldiloader/association_options.rb
goldiloader-3.0.0 lib/goldiloader/association_options.rb