Permalink
Browse files

[#4468] Background Cache Optimization DSL Config Loading

  • Loading branch information...
1 parent b04ef78 commit 890a7b96dfdda77e1bd358e3a2c2d852893ef930 @winton committed Jun 29, 2011
Showing with 10 additions and 6 deletions.
  1. +1 −1 lib/background_cache.rb
  2. +9 −5 lib/background_cache/config.rb
View
@@ -17,6 +17,7 @@ def self.active?
def self.cache!(group=nil)
instance = self.boot
+ BackgroundCache::Config.load!(group)
caches = BackgroundCache::Config.caches
caches.each do |cache|
next if group && cache[:group] != group
@@ -44,7 +45,6 @@ def self.match?(controller, fragment={})
def self.boot
instance = AppInstance.new
- BackgroundCache::Config.load!
instance
end
end
@@ -4,7 +4,7 @@ module BackgroundCache
class Config
class <<self
- attr_accessor :current_cache
+ attr_accessor :current_cache, :group
end
def initialize(&block)
@@ -23,7 +23,9 @@ def except(value, &block)
end
def group(value, &block)
- set_option({ :group => value }, &block)
+ if self.class.group.nil? || value == self.class.group
+ set_option({ :group => value }, &block)
+ end
end
def layout(value, &block)
@@ -84,7 +86,7 @@ def self.match?(controller, fragment={})
cache[:only] == fragment ||
(
# :only is an array
- cache[:only].respond_to?(:index) &&
+ cache[:only].respond_to?(:compact) &&
# :only includes matching fragment
cache[:only].include?(fragment)
)
@@ -96,7 +98,7 @@ def self.match?(controller, fragment={})
cache[:except] != fragment ||
(
# :except is an array
- cache[:except].respond_to?(:index) &&
+ cache[:except].respond_to?(:compact) &&
# :except does not include matching fragment
!cache[:except].include?(fragment)
)
@@ -109,8 +111,10 @@ def self.caches
defined?(@@caches) ? @@caches : []
end
- def self.load!
+ def self.load!(group=nil)
+ self.group = group
load RAILS_ROOT + "/lib/background_cache_config.rb"
+ self.group = nil
end
def self.unload!

0 comments on commit 890a7b9

Please sign in to comment.