Sha256: 71eea57c9e3e3fa5b4abb2a11b568522c3c7efee77e7d51537dbf6a347dbc781

Contents?: true

Size: 1.09 KB

Versions: 2

Compression:

Stored size: 1.09 KB

Contents

module Netzke
  # This modules provides (component-specific) session manupulation.
  # The :session_persistence config option should be set to true in order for the component to make use of this.
  module Session
    # Top-level session (straight from the controller).
    def session
      ::Netzke::Core.session
    end

    # Component-specific session.
    def component_session
      session[global_id] ||= {}
    end

    # Returns this component's configuration options stored in the session. Those get merged into the component's configuration at instantiation.
    def session_options
      session_persistence_enabled? && component_session[:options] || {}
    end

    # Updates the session options
    def update_session_options(hash)
      if session_persistence_enabled?
        component_session[:options] ||= {}
        component_session[:options].merge!(hash)
      else
        logger.debug "Netzke warning: No session persistence enabled for component '#{global_id}'"
      end
    end

    private
      def session_persistence_enabled?
        initial_config[:session_persistence]
      end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
netzke-core-0.6.4 lib/netzke/session.rb
netzke-core-0.6.3 lib/netzke/session.rb