Module: Rack::Cache::Options

### Home Classes Methods

### In Files

- lib/rack/cache/options.rb

### Methods

- ::option_accessor
- ::option_name
- #options
- #options=
- #set

### Files

- CHANGES
- COPYING
- README
- TODO

### Class/Module Index

Quicksearch

- Rack
- Rack::Cache
- Rack::Cache::AppEngine
- Rack::Cache::AppEngine::MC
- Rack::Cache::AppEngine::MemCache
- Rack::Cache::CacheControl
- Rack::Cache::Context
- Rack::Cache::EntityStore
- Rack::Cache::EntityStore::DISK
- Rack::Cache::EntityStore::Dalli
- Rack::Cache::EntityStore::Disk
- Rack::Cache::EntityStore::FILE
- Rack::Cache::EntityStore::GAE
- Rack::Cache::EntityStore::GAECACHE
- Rack::Cache::EntityStore::GAEStore
- Rack::Cache::EntityStore::HEAP
- Rack::Cache::EntityStore::Heap
- Rack::Cache::EntityStore::MEM
- Rack::Cache::EntityStore::MemCacheBase
- Rack::Cache::EntityStore::MemCached
- Rack::Cache::Key
- Rack::Cache::MetaStore
- Rack::Cache::MetaStore::DISK
- Rack::Cache::MetaStore::Dalli
- Rack::Cache::MetaStore::Disk
- Rack::Cache::MetaStore::FILE
- Rack::Cache::MetaStore::GAE
- Rack::Cache::MetaStore::GAECACHE
- Rack::Cache::MetaStore::GAEStore
- Rack::Cache::MetaStore::HEAP
- Rack::Cache::MetaStore::Heap
- Rack::Cache::MetaStore::MEM
- Rack::Cache::MetaStore::MemCacheBase
- Rack::Cache::MetaStore::MemCached
- Rack::Cache::Options
- Rack::Cache::Request
- Rack::Cache::Response
- Rack::Cache::Storage

No matching classes.

# Rack::Cache::Options

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.

### Public Class Methods

option_accessor(key) click to toggle source

    # File lib/rack/cache/options.rb, line 13
    def self.option_accessor(key)
      name = option_name(key)
      define_method(key) { || options[name] }
      define_method("#{key}=") { |value| options[name] = value }
      define_method("#{key}?") { || !! options[name] }
    end

option_name(key) click to toggle source

    # File lib/rack/cache/options.rb, line 20
    def option_name(key)
      case key
      when Symbol ; "rack-cache.#{key}"
      when String ; key
      else raise ArgumentError
      end
    end

### Public Instance Methods

options() click to toggle source

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
    def options
      @env || @default_options
    end

options=(hash={}) click to toggle source

Set multiple options.

    # File lib/rack/cache/options.rb, line 121
    def options=(hash={})
      hash.each { |key,value| write_option(key, value) }
    end

set(option, value=self, &block) click to toggle source

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.

    # File lib/rack/cache/options.rb, line 130
    def set(option, value=self, &block)
      if block_given?
        write_option option, block
      elsif value == self
        self.options = option.to_hash
      else
        write_option option, value
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.