Browse files

Added Rails::Configuration support for fragment stores

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2223 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 691f95e commit 87e7ed8aef159674447b75b83746ba0e7d2e44e3 @dhh dhh committed Sep 12, 2005
Showing with 20 additions and 2 deletions.
  1. +4 −0 railties/environments/environment.rb
  2. +16 −2 railties/lib/initializer.rb
View
4 railties/environments/environment.rb
@@ -22,6 +22,10 @@
# (create the session table with 'rake create_sessions_table')
# config.session_options[:database_manager] = CGI::Session::ActiveRecordStore
+ # Enable page/fragment caching by setting a file-based store
+ # (remember to create the caching directory and make it readable to the application)
+ # config.fragment_store = :file_store, "#{RAILS_ROOT}/cache"
+
# See Rails::Configuration for more options
end
View
18 railties/lib/initializer.rb
@@ -40,6 +40,7 @@ def process
initialize_framework_views
initialize_routing
initialize_session_settings
+ initialize_fragment_store
end
def set_load_path
@@ -97,9 +98,22 @@ def initialize_routing
end
def initialize_session_settings
- return if !configuration.frameworks.include?(:action_controller)
+ return unless configuration.frameworks.include?(:action_controller)
ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS.merge!(configuration.session_options)
end
+
+ def initialize_fragment_store
+ return if !configuration.frameworks.include?(:action_controller) || configuration.fragment_store.nil?
+
+ configuration.fragment_store = [ configuration.fragment_store ].flatten
+ store = ActionController::Caching::Fragments.const_get(configuration.fragment_store.first.to_s.camelize)
+
+ if parameters = configuration.fragment_store[1..-1]
+ ActionController::Base.fragment_cache_store = store.new(*parameters)
+ else
+ ActionController::Base.fragment_cache_store = store.new
+ end
+ end
end
# The Configuration class holds all the parameters for the Initializer and ships with defaults that suites most
@@ -111,7 +125,7 @@ def initialize_session_settings
# Rails::Initializer.run(:process, config)
class Configuration
attr_accessor :frameworks, :load_paths, :log_level, :log_path, :database_configuration_file, :view_path, :controller_paths
- attr_accessor :session_options
+ attr_accessor :session_options, :fragment_store
def initialize
self.frameworks = default_frameworks

0 comments on commit 87e7ed8

Please sign in to comment.