Sha256: 2a95a6544aedffdaaef8a4771617512f2887b6be979d3899c2285021dc54df98
Contents?: true
Size: 749 Bytes
Versions: 10
Compression:
Stored size: 749 Bytes
Contents
# frozen_string_literal: true module Maglev # Retrieve a page from a path and a locale # (previously extracted by the ExtractLocale service) class FetchPage include Injectable argument :path argument :locale argument :default_locale argument :fallback_to_default_locale, default: false argument :only_visible, default: false def call page = fetch_page(path, locale) page = fetch_page(path, default_locale) if !page && fallback_to_default_locale page end protected def fetch_page(path, locale) page = pages.by_path(path || 'index', locale).first !only_visible || (page&.visible? && only_visible) ? page : nil end def pages Maglev::Page end end end
Version data entries
10 entries across 10 versions & 1 rubygems