Sha256: c1a2cb1138c34e6428bf0f1b9f69ed81aa82719514896e5a4aa13b554a67523f

Contents?: true

Size: 975 Bytes

Versions: 46

Compression:

Stored size: 975 Bytes

Contents

module Fiona7
  class EditingEnvCheck
    def initialize(env)
      self.env = env
      self.editing_context = self.env[Scrivito::EditingContextMiddleware::ENVKEY]
    end

    def rtc_selected?
      editing_context && editing_context.authenticated_editor? && selected_workspace_id == 'rtc'
    end

    def editing_mode?
      rtc_selected? && editing_context && editing_context.authenticated_editor? && selected_display_mode == 'editing'
    end

    protected
    attr_accessor :env
    attr_accessor :editing_context

    private
    def selected_workspace_id
      # NOTE: this does not require workspace lookup/load_obj
      # and thus is potentially faster
      self.editing_context.instance_variable_get(:@selected_workspace_id).to_s
    end

    def selected_display_mode
      # NOTE: this does not require workspace lookup/load_obj
      # and thus is potentially faster
      self.editing_context.instance_variable_get(:@display_mode).to_s
    end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
infopark_fiona7-0.71.1.12 lib/fiona7/editing_env_check.rb
infopark_fiona7-0.71.1.11 lib/fiona7/editing_env_check.rb
infopark_fiona7-0.71.1.10 lib/fiona7/editing_env_check.rb
infopark_fiona7-0.71.1.1 lib/fiona7/editing_env_check.rb
infopark_fiona7-0.71.1.0 lib/fiona7/editing_env_check.rb
infopark_fiona7-0.71.0.7 lib/fiona7/editing_env_check.rb