Class: Fiona7::Middleware::TableSwitchingMiddleware
- Inherits:
-
Object
- Object
- Fiona7::Middleware::TableSwitchingMiddleware
- Defined in:
- lib/fiona7/middleware/table_switching_middleware.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ TableSwitchingMiddleware
constructor
A new instance of TableSwitchingMiddleware.
- #selected_workspace_id(editing_context) ⇒ Object
Constructor Details
#initialize(app) ⇒ TableSwitchingMiddleware
Returns a new instance of TableSwitchingMiddleware.
6 7 8 |
# File 'lib/fiona7/middleware/table_switching_middleware.rb', line 6 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/fiona7/middleware/table_switching_middleware.rb', line 10 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 |
#selected_workspace_id(editing_context) ⇒ Object
27 28 29 30 31 |
# File 'lib/fiona7/middleware/table_switching_middleware.rb', line 27 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 |