Sha256: 1daad0c79d8f118602d0a8a34c8c52eec38774edfe30dd394ac683323406a376

Contents?: true

Size: 1 KB

Versions: 56

Compression:

Stored size: 1 KB

Contents

# frozen_string_literal: true

module Alchemy
  # Eager loading parameters for loading pages
  class EagerLoading
    PAGE_VERSIONS = %i[draft_version public_version]

    class << self
      # Eager loading parameters for {ActiveRecord::Base.includes}
      #
      # Pass this to +includes+ whereever you load an {Alchemy::Page}
      #
      #     Alchemy::Page.includes(Alchemy::EagerLoading.page_includes).find_by(urlname: "my-page")
      #
      # @param version [Symbol] Type of page version to eager load
      # @return [Array]
      def page_includes(version: :public_version)
        raise UnsupportedPageVersion unless version.in? PAGE_VERSIONS

        [
          :tags,
          {
            :language => :site,
            version => {
              elements: [
                :page,
                :touchable_pages,
                :tags,
                {
                  ingredients: :related_object
                }
              ]
            }
          }
        ]
      end
    end
  end
end

Version data entries

56 entries across 56 versions & 1 rubygems

Version Path
alchemy_cms-7.4.2 app/models/alchemy/eager_loading.rb
alchemy_cms-7.3.6 app/models/alchemy/eager_loading.rb
alchemy_cms-7.2.9 app/models/alchemy/eager_loading.rb
alchemy_cms-7.4.1 app/models/alchemy/eager_loading.rb
alchemy_cms-7.4.0 app/models/alchemy/eager_loading.rb
alchemy_cms-7.3.5 app/models/alchemy/eager_loading.rb
alchemy_cms-7.2.8 app/models/alchemy/eager_loading.rb
alchemy_cms-7.1.13 app/models/alchemy/eager_loading.rb
alchemy_cms-7.0.16 app/models/alchemy/eager_loading.rb
alchemy_cms-7.3.4 app/models/alchemy/eager_loading.rb
alchemy_cms-7.3.3 app/models/alchemy/eager_loading.rb
alchemy_cms-7.3.2 app/models/alchemy/eager_loading.rb
alchemy_cms-7.2.7 app/models/alchemy/eager_loading.rb
alchemy_cms-7.3.1 app/models/alchemy/eager_loading.rb
alchemy_cms-7.3.0 app/models/alchemy/eager_loading.rb
alchemy_cms-7.2.6 app/models/alchemy/eager_loading.rb
alchemy_cms-7.2.5 app/models/alchemy/eager_loading.rb
alchemy_cms-7.1.12 app/models/alchemy/eager_loading.rb
alchemy_cms-7.0.15 app/models/alchemy/eager_loading.rb
alchemy_cms-7.2.4 app/models/alchemy/eager_loading.rb