lib/model_cache.rb in model-cache-0.1.2 vs lib/model_cache.rb in model-cache-0.1.3

- old
+ new

@@ -1,9 +1,9 @@ module ModelCache - DEFAULT_TIME = 12.hours - @@nil_object ||= Object.new + DEFAULT_TIME = 12.hours unless const_defined?(:DEFAULT_TIME) + NIL_OBJECT = Object.new unless const_defined?(:NIL_OBJECT) def self.included(klass) klass.extend ClassMethods end @@ -11,21 +11,21 @@ ModelCache::cache([self.cache_key, key], time, &block) end def self.cache(ckey, time = DEFAULT_TIME, &block) if Rails.configuration.action_controller.perform_caching && (result = CACHE.get(ckey)) - if result == @@nil_object + if result == NIL_OBJECT nil else result end else result = block.call if Rails.configuration.action_controller.perform_caching if result CACHE.set(ckey, result, time) else - CACHE.set(ckey, @@nil_object, time) + CACHE.set(ckey, NIL_OBJECT, time) end end result end end \ No newline at end of file