Sha256: 89629a8fe84f667aafaa61c4060ad550c14fb3ff435730788d97da3c25390946

Contents?: true

Size: 1.13 KB

Versions: 4

Compression:

Stored size: 1.13 KB

Contents

module Mack
  
  # A holder for the session information. This objects gets stored using the Cachetastic system.
  # For more information about how Cachetastic works see the RDoc for that gem.
  # The session cookie name defaults to: _mack_session_id but can be changed using the application_configuration
  # system like such:
  #   mack::session_id: _my_cool_app_sess_id
  class Session
    
    attr_reader :id # The id of the session.
    
    def initialize(id)
      @id = id
      @sess_hash = {}
    end
    
    # Finds what you're looking for in the session, if it exists.
    # If what you're looking for doesn't exist, it returns nil.
    def [](key)
      sess_hash[key.to_sym]
    end
    
    # Sets a value into the session.
    def []=(key, value)
      sess_hash[key.to_sym] = value
    end
    
    # Clears out the session.
    def reset!
      @sess_hash = {}
    end
    
    # Deletes a value from the session
    def delete(key)
      @sess_hash.delete(key.to_sym)
    end
    
    def inspect
      "#{self.id}: #{@sess_hash.inspect}"
    end
    
    private
    attr_reader :sess_hash # :nodoc:
    
  end # Session
  
end # Mack

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mack-0.7.0.1 lib/mack/controller/session.rb
mack-0.7.0 lib/mack/controller/session.rb
mack-0.7.1.1 lib/mack/sessions/session.rb
mack-0.7.1 lib/mack/sessions/session.rb