Sha256: be599e48c98c05d528c01f9afe3fee7d60e82f4e37645c455de87e8ffea1fd7b

Contents?: true

Size: 952 Bytes

Versions: 9

Compression:

Stored size: 952 Bytes

Contents

module Netzke::Core
  # Implements component-specific session manupulation.
  module Session
    # Instance of this class is returned through component_session, and allows writing/reading to/from the session part reserved for a specific component (specified by component's js_id).
    class ComponentSessionProxy < Object
      def initialize(component_id)
        @component_id = component_id
        Netzke::Base.session ||= {}
        Netzke::Base.session[:netzke_sessions] ||= {}
        @session = Netzke::Base.session[:netzke_sessions][@component_id] ||= {}
      end

      # Delegate everything to session
      def method_missing(method, *args)
        @session.send(method, *args)
      end

      def clear
        Netzke::Base.session[:netzke_sessions].delete(@component_id)
      end
    end

    # Component-specific session.
    def component_session
      @component_session_proxy ||= ComponentSessionProxy.new(js_id)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
netzke-core-0.10.1 lib/netzke/core/session.rb
netzke-core-0.10.0 lib/netzke/core/session.rb
netzke-core-0.9.0 lib/netzke/core/session.rb
netzke-core-0.10.0.rc2 lib/netzke/core/session.rb
netzke-core-0.10.0.rc1 lib/netzke/core/session.rb
netzke-core-0.9.0.rc1 lib/netzke/core/session.rb
netzke-core-0.8.4 lib/netzke/core/session.rb
netzke-core-0.8.3 lib/netzke/core/session.rb
netzke-core-0.8.2 lib/netzke/core/session.rb