Sha256: 076785e2f9787933fd00fc1714f52397b468a8096460e246af4d3aafe9a8e09a
Contents?: true
Size: 790 Bytes
Versions: 16
Compression:
Stored size: 790 Bytes
Contents
module Scrivito class CmsEnv OBJ_ENV_KEY = "SCRIVITO_OBJ" def initialize(env) @env = env end def load return if env[OBJ_ENV_KEY] load_object end protected attr_reader :env def load_object env[OBJ_ENV_KEY] = begin find_obj rescue StandardError => e e end end def find_obj found_obj = if params[:id] Obj.find(params[:id]) elsif params[:permalink].present? permalink = Array(params[:permalink]).join("/") Obj.find_by_permalink!(permalink) else Scrivito::RequestHomepage.call(env) end found_obj end def params env["action_dispatch.request.path_parameters"] end end end
Version data entries
16 entries across 16 versions & 1 rubygems