aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib')
-rwxr-xr-xactionpack/lib/action_controller.rb2
-rw-r--r--actionpack/lib/action_controller/caching.rb37
-rw-r--r--actionpack/lib/action_controller/cgi_process.rb5
-rw-r--r--actionpack/lib/action_controller/session.rb14
-rw-r--r--actionpack/lib/action_controller/session_management.rb21
5 files changed, 41 insertions, 38 deletions
diff --git a/actionpack/lib/action_controller.rb b/actionpack/lib/action_controller.rb
index 0eaf630bbe..cdc9102062 100755
--- a/actionpack/lib/action_controller.rb
+++ b/actionpack/lib/action_controller.rb
@@ -38,7 +38,6 @@ require 'action_controller/benchmarking'
require 'action_controller/filters'
require 'action_controller/layout'
require 'action_controller/flash'
-require 'action_controller/session'
require 'action_controller/dependencies'
require 'action_controller/pagination'
require 'action_controller/scaffolding'
@@ -67,7 +66,6 @@ ActionController::Base.class_eval do
include ActionController::Scaffolding
include ActionController::Helpers
include ActionController::Cookies
- include ActionController::Session
include ActionController::Caching
include ActionController::Components
include ActionController::Verification
diff --git a/actionpack/lib/action_controller/caching.rb b/actionpack/lib/action_controller/caching.rb
index 095fb7f2f2..88529d8008 100644
--- a/actionpack/lib/action_controller/caching.rb
+++ b/actionpack/lib/action_controller/caching.rb
@@ -240,23 +240,28 @@ module ActionController #:nodoc:
#
# Configuration examples (MemoryStore is the default):
#
- # ActionController::Base.fragment_cache_store =
- # ActionController::Caching::Fragments::MemoryStore.new
- #
- # ActionController::Base.fragment_cache_store =
- # ActionController::Caching::Fragments::FileStore.new("/path/to/cache/directory")
- #
- # ActionController::Base.fragment_cache_store =
- # ActionController::Caching::Fragments::DRbStore.new("druby://localhost:9192")
- #
- # ActionController::Base.fragment_cache_store =
- # ActionController::Caching::Fragments::MemCacheStore.new("localhost")
+ # ActionController::Base.fragment_cache_store = :memory_store
+ # ActionController::Base.fragment_cache_store = :file_store, "/path/to/cache/directory"
+ # ActionController::Base.fragment_cache_store = :drb_store, "druby://localhost:9192"
+ # ActionController::Base.fragment_cache_store = :mem_cache_store, "localhost"
+ # ActionController::Base.fragment_cache_store = MyOwnStore.new("parameter")
module Fragments
def self.append_features(base) #:nodoc:
super
base.class_eval do
@@fragment_cache_store = MemoryStore.new
- cattr_accessor :fragment_cache_store
+ cattr_reader :fragment_cache_store
+
+ def self.fragment_cache_store=(store_option)
+ store, *parameters = *([ store_option ].flatten)
+ @@fragment_cache_store = if store.is_a?(Symbol)
+ store_class_name = (store == :drb_store ? "DRbStore" : store.to_s.camelize)
+ store_class = ActionController::Caching::Fragments.const_get(store_class_name)
+ parameters.empty? ? store.new : store_class.new(*parameters)
+ else
+ store
+ end
+ end
end
end
@@ -349,18 +354,26 @@ module ActionController #:nodoc:
end
class DRbStore < MemoryStore #:nodoc:
+ attr_reader :address
+
def initialize(address = 'druby://localhost:9192')
+ @address = address
@data, @mutex = DRbObject.new(nil, address), Mutex.new
end
end
class MemCacheStore < MemoryStore #:nodoc:
+ attr_reader :address
+
def initialize(address = 'localhost')
+ @address = address
@data, @mutex = MemCache.new(address), Mutex.new
end
end
class FileStore #:nodoc:
+ attr_reader :cache_path
+
def initialize(cache_path)
@cache_path = cache_path
end
diff --git a/actionpack/lib/action_controller/cgi_process.rb b/actionpack/lib/action_controller/cgi_process.rb
index e9e539cfdc..d59de771c9 100644
--- a/actionpack/lib/action_controller/cgi_process.rb
+++ b/actionpack/lib/action_controller/cgi_process.rb
@@ -1,11 +1,6 @@
require 'action_controller/cgi_ext/cgi_ext'
require 'action_controller/cgi_ext/cookie_performance_fix'
require 'action_controller/cgi_ext/raw_post_data_fix'
-require 'action_controller/session/drb_store'
-require 'action_controller/session/mem_cache_store'
-if Object.const_defined?(:ActiveRecord)
- require 'action_controller/session/active_record_store'
-end
module ActionController #:nodoc:
class Base
diff --git a/actionpack/lib/action_controller/session.rb b/actionpack/lib/action_controller/session.rb
deleted file mode 100644
index f3c3f87499..0000000000
--- a/actionpack/lib/action_controller/session.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-module ActionController #:nodoc:
- module Session #:nodoc:
- def self.append_features(base) #:nodoc:
- super #:nodoc:
- base.after_filter(:clear_persistant_model_associations)
- end
-
- private
- def clear_persistant_model_associations #:doc:
- session = @session.instance_variable_get("@data")
- session.each { |key, obj| obj.clear_association_cache if obj.respond_to?(:clear_association_cache) } if session
- end
- end
-end \ No newline at end of file
diff --git a/actionpack/lib/action_controller/session_management.rb b/actionpack/lib/action_controller/session_management.rb
index 193910d470..b0a457932d 100644
--- a/actionpack/lib/action_controller/session_management.rb
+++ b/actionpack/lib/action_controller/session_management.rb
@@ -1,12 +1,17 @@
+require 'action_controller/session/drb_store'
+require 'action_controller/session/mem_cache_store'
+if Object.const_defined?(:ActiveRecord)
+ require 'action_controller/session/active_record_store'
+end
+
module ActionController #:nodoc:
module SessionManagement #:nodoc:
def self.append_features(base)
super
base.extend(ClassMethods)
- base.class_eval do
- alias_method :process_without_session_management_support, :process
- alias_method :process, :process_with_session_management_support
- end
+ base.send(:alias_method, :process_without_session_management_support, :process)
+ base.send(:alias_method, :process, :process_with_session_management_support)
+ base.after_filter(:clear_persistant_model_associations)
end
module ClassMethods
@@ -15,7 +20,7 @@ module ActionController #:nodoc:
# :mem_cache_store, or :memory_store) or use your own class.
def session_store=(store)
ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS[:database_manager] =
- store.is_a?(Symbol) ? CGI::Session.const_get(store.to_s.camelize) : store
+ store.is_a?(Symbol) ? CGI::Session.const_get(store == :drb_store ? "DRbStore" : store.to_s.camelize) : store
end
# Returns the session store class currently used.
@@ -100,5 +105,11 @@ module ActionController #:nodoc:
request.session_options = self.class.session_options_for(request, action)
process_without_session_management_support(request, response, method, *arguments)
end
+
+ private
+ def clear_persistant_model_associations #:doc:
+ session = @session.instance_variable_get("@data")
+ session.each { |key, obj| obj.clear_association_cache if obj.respond_to?(:clear_association_cache) } if session
+ end
end
end