Sha256: 1eaa608919008301574d79a09640cfe364a7c4a34514f3f8ad60593b0118846b
Contents?: true
Size: 1.33 KB
Versions: 4
Compression:
Stored size: 1.33 KB
Contents
module CachedResource # The Configuration class manages class specific options # for cached resource. class Configuration < OpenStruct # default or fallback cache without rails CACHE = ActiveSupport::Cache::MemoryStore.new # default of fallback logger without rails LOGGER = ActiveSupport::BufferedLogger.new(NilIO.new) # prefix for log messages LOGGER_PREFIX = "[cached_resource]" # Initialize a Configuration with the given options, overriding any # defaults. The following options exist for cached resource: # :enabled, default: true # :ttl, default: 604800 # :collection_synchronize, default: false, # :collection_arguments, default: [:all] # :cache, default: Rails.cache or ActiveSupport::Cache::MemoryStore.new, # :logger, default: Rails.logger or ActiveSupport::BufferedLogger.new(NilIO.new) def initialize(options={}) super({ :enabled => true, :ttl => 604800, :collection_synchronize => false, :collection_arguments => [:all], :cache => defined?(Rails.cache) && Rails.cache || CACHE, :logger => defined?(Rails.logger) && Rails.logger || LOGGER }.merge(options)) end # Enables caching. def on! self.enabled = true end # Disables caching. def off! self.enabled = false end end end
Version data entries
4 entries across 4 versions & 1 rubygems