lib/configure_me/caching.rb in configure_me-0.3.2 vs lib/configure_me/caching.rb in configure_me-0.4.0
- old
+ new
@@ -1,25 +1,30 @@
-require 'active_support/concern'
-
module ConfigureMe
- module Caching
- extend ActiveSupport::Concern
-
- included do
- @caching = false
- end
-
- module ClassMethods
- def cache_me(caching_key = nil)
+ class Base
+ class << self
+ def cache_me
@caching = true
end
def caching?
- @caching
+ @caching ||= false
+ @caching && !ConfigureMe.cache_object.nil?
end
end
+ end
- def cache_key(name)
- persistence_key(name)
+ module Caching
+ def read_cache(name)
+ if self.class.caching?
+ ConfigureMe.cache_object.read(self.storage_key(name))
+ else
+ nil
+ end
+ end
+
+ def write_cache(name, value)
+ if self.class.caching?
+ ConfigureMe.cache_object.write(self.storage_key(name), value)
+ end
end
end
end