Module: Rack::Cache::Options
- Included in:
- Context
- Defined in:
- lib/rack/cache/options.rb
Overview
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.<option>”, where <option> is the option name.
The #set method can be used to configure a option values. When #set is called outside of request scope, the value applies to all requests; when called from within a request context, applies only to the request being processed.
Instance Method Summary collapse
-
#options ⇒ Object
The underlying options Hash.
-
#options=(hash = {}) ⇒ Object
Set multiple options.
-
#set(option, value = self, &block) ⇒ Object
Set an option.
Instance Method Details
#options ⇒ Object
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.
90 91 92 |
# File 'lib/rack/cache/options.rb', line 90 def @env || end |
#options=(hash = {}) ⇒ Object
Set multiple options.
95 96 97 |
# File 'lib/rack/cache/options.rb', line 95 def (hash={}) hash.each { |key,value| write_option(key, value) } end |
#set(option, value = self, &block) ⇒ Object
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 #set method were called on each.
104 105 106 107 108 109 110 111 112 |
# File 'lib/rack/cache/options.rb', line 104 def set(option, value=self, &block) if block_given? write_option option, block elsif value == self self. = option.to_hash else write_option option, value end end |