lib/amfetamine/base.rb in amfetamine-0.2.11 vs lib/amfetamine/base.rb in amfetamine-0.2.12
- old
+ new
@@ -108,10 +108,14 @@
else
@cache_server = Amfetamine::Cache.new(value, options)
end
end
+ def self.disable_caching=(value)
+ @disable_caching = value
+ end
+
# Base method for creating objects
def initialize(args={})
super
@attributes = {}
self.set_dynamic_attributes(args.keys)
@@ -151,12 +155,17 @@
def cached?
self.cache_key ? cache.get(self.cache_key).present? : false
end
# Checks if object is cachable
- # TODO implement
def self.cacheable?
- true
+ if @disable_caching == true
+ false
+ elsif Amfetamine::Config.disable_caching == true
+ false
+ else
+ true
+ end
end
def cacheable?
self.class.cacheable?
end