Class: Ramaze::Session::Hash
- Defined in:
- lib/ramaze/current/session/hash.rb
Overview
The Session::Hash acts as the wrapper for a simple Hash
Its purpose is to notify the underlying cache, in which the sessions are stored, about updates.
Instance Method Summary collapse
-
#client ⇒ Object
Use client side session variables.
-
#initialize(sess) ⇒ Hash
constructor
Sets @hash to an empty Hash.
-
#inspect ⇒ Object
Calls #inspect on the wrapped @hash.
-
#method_missing(*args, &block) ⇒ Object
relays all the methods to the @hash and updates the session_cache in Session.current.sessions if anything changes.
Constructor Details
#initialize(sess) ⇒ Hash
Sets @hash to an empty Hash
12 13 14 15 |
# File 'lib/ramaze/current/session/hash.rb', line 12 def initialize sess @session = sess @hash = {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*args, &block) ⇒ Object
relays all the methods to the @hash and updates the session_cache in Session.current.sessions if anything changes.
20 21 22 23 24 25 26 27 |
# File 'lib/ramaze/current/session/hash.rb', line 20 def method_missing(*args, &block) old = @hash.dup result = @hash.send(*args, &block) unless old == @hash Cache.sessions[@session.session_id] = self end result end |
Instance Method Details
#client ⇒ Object
Use client side session variables
37 38 39 |
# File 'lib/ramaze/current/session/hash.rb', line 37 def client Request.current['session.client'] ||= unmarshal(Request.current.["#{Session::SESSION_KEY}-client"]) || {} end |
#inspect ⇒ Object
Calls #inspect on the wrapped @hash
31 32 33 |
# File 'lib/ramaze/current/session/hash.rb', line 31 def inspect @hash.inspect end |