aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/session
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_controller/session')
-rw-r--r--actionpack/lib/action_controller/session/active_record_store.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/actionpack/lib/action_controller/session/active_record_store.rb b/actionpack/lib/action_controller/session/active_record_store.rb
index a653947038..90a84511be 100644
--- a/actionpack/lib/action_controller/session/active_record_store.rb
+++ b/actionpack/lib/action_controller/session/active_record_store.rb
@@ -5,6 +5,16 @@ require 'base64'
class CGI
class Session
+ # Return this session's underlying Session model. Useful for the DB-backed session stores.
+ def model
+ @dbman.model rescue nil
+ end
+
+ # Proxy missing methods to the underlying Session model.
+ def method_missing(method, *args, &block)
+ if model then model.send(method, *args, &block) else super end
+ end
+
# A session store backed by an Active Record class.
#
# A default class is provided, but any object duck-typing to an Active
@@ -277,6 +287,11 @@ class CGI
end
end
+ # Access the underlying session model.
+ def model
+ @session
+ end
+
# Restore session state. The session model handles unmarshaling.
def restore
if @session