Sha256: 72b20fee495903b6b39e9b5ea6fa876943b4c7ca4f4d8e9630b1387f1399d95a

Contents?: true

Size: 1.04 KB

Versions: 17

Compression:

Stored size: 1.04 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,
                  contents: :essence,
                },
              ],
            },
          },
        ]
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
alchemy_cms-6.1.10 app/models/alchemy/eager_loading.rb
alchemy_cms-6.1.9 app/models/alchemy/eager_loading.rb
alchemy_cms-6.1.8 app/models/alchemy/eager_loading.rb
alchemy_cms-6.1.7 app/models/alchemy/eager_loading.rb
alchemy_cms-6.1.6 app/models/alchemy/eager_loading.rb
alchemy_cms-6.1.5 app/models/alchemy/eager_loading.rb
alchemy_cms-6.0.14 app/models/alchemy/eager_loading.rb
alchemy_cms-6.1.4 app/models/alchemy/eager_loading.rb
alchemy_cms-6.0.13 app/models/alchemy/eager_loading.rb
alchemy_cms-6.1.3 app/models/alchemy/eager_loading.rb
alchemy_cms-6.1.2 app/models/alchemy/eager_loading.rb
alchemy_cms-6.1.1 app/models/alchemy/eager_loading.rb
alchemy_cms-6.1.0 app/models/alchemy/eager_loading.rb
alchemy_cms-6.0.12 app/models/alchemy/eager_loading.rb
alchemy_cms-6.0.11 app/models/alchemy/eager_loading.rb
alchemy_cms-6.0.10 app/models/alchemy/eager_loading.rb
alchemy_cms-6.0.9 app/models/alchemy/eager_loading.rb