Configuration options and utility methods for option access. Rack::Cache uses the Rack Environment to store option values. All options documented below are stored in the Rack Environment as “rack-cache.
# File lib/rack/cache/options.rb, line 13 13: def self.option_accessor(key) 14: name = option_name(key) 15: define_method(key) { || options[name] } 16: define_method("#{key}=") { |value| options[name] = value } 17: define_method("#{key}?") { || !! options[name] } 18: end
The underlying options Hash. During initialization (or outside of a request), this is a default values Hash. During a request, this is the Rack environment Hash. The default values Hash is merged in underneath the Rack environment before each request is processed.
# File lib/rack/cache/options.rb, line 116 116: def options 117: @env || @default_options 118: end
Set multiple options.
# File lib/rack/cache/options.rb, line 121 121: def options=(hash={}) 122: hash.each { |key,value| write_option(key, value) } 123: end
Set an option. When option is a Symbol, it is set in the Rack Environment as “rack-cache.option“. When option is a String, it exactly as specified. The option argument may also be a Hash in which case each key/value pair is merged into the environment as if the # method were called on each.
# File lib/rack/cache/options.rb, line 130 130: def set(option, value=self, &block) 131: if block_given? 132: write_option option, block 133: elsif value == self 134: self.options = option.to_hash 135: else 136: write_option option, value 137: end 138: end
# File lib/rack/cache/options.rb, line 141 141: def initialize_options(options={}) 142: @default_options = { 143: 'rack-cache.cache_key' => Key, 144: 'rack-cache.verbose' => true, 145: 'rack-cache.storage' => Rack::Cache::Storage.instance, 146: 'rack-cache.metastore' => 'heap:/', 147: 'rack-cache.entitystore' => 'heap:/', 148: 'rack-cache.default_ttl' => 0, 149: 'rack-cache.ignore_headers' => ['Set-Cookie'], 150: 'rack-cache.private_headers' => ['Authorization', 'Cookie'], 151: 'rack-cache.allow_reload' => false, 152: 'rack-cache.allow_revalidate' => false, 153: 'rack-cache.use_native_ttl' => false, 154: } 155: self.options = options 156: end
# File lib/rack/cache/options.rb, line 20 20: def option_name(key) 21: case key 22: when Symbol ; "rack-cache.#{key}" 23: when String ; key 24: else raise ArgumentError 25: end 26: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.