module Scrivito module RequestHomepage HOMEPAGE_ENV_KEY = "SCRIVITO_HOMEPAGE" def self.call(env) env[HOMEPAGE_ENV_KEY] ||= fetch_homepage(env) end private_class_method def self.fetch_homepage(env) callback_result = Scrivito::Configuration.choose_homepage_callback.call(env) if callback_result.is_a?(Scrivito::BasicObj) callback_result else raise "choose_homepage callback did not return an Obj. "\ "Instead saw #{callback_result.class}." end end end end