Sha256: d0c9b9496a8a5b20d89c1f183ed808d90651e0b06b7e8a033711b2c8b1f13a0b
Contents?: true
Size: 1.01 KB
Versions: 23
Compression:
Stored size: 1.01 KB
Contents
require "fiona7/table_switcher" module Fiona7 module Middleware class TableSwitchingMiddleware def initialize(app) @app = app end def call(env) if Fiona7.mode == :legacy editing_context = env[Scrivito::EditingContextMiddleware::ENVKEY] use_preview = editing_context.authenticated_editor? && selected_workspace_id(editing_context) == 'rtc' (Fiona7::WriteObj.base_class.descendants - [Fiona7::ReleasedObj, Fiona7::InternalReleasedObj, Fiona7::EditedObj] + [Fiona7::WriteObj.base_class]).each do |descendant| TableSwitcher.new( descendant, use_preview ? "preview_objs" : "objs" ).switch end end @app.call(env) end def selected_workspace_id(editing_context) # NOTE: this does not require workspace lookup/load_obj # and thus is potentially faster editing_context.instance_variable_get(:@selected_workspace_id).to_s end end end end
Version data entries
23 entries across 23 versions & 1 rubygems