module Rack::Cache::Options

def self.option_accessor(key)

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

def initialize_options(options={})

def initialize_options(options={})
  @default_options = {
    'rack-cache.cache_key'        => Key,
    'rack-cache.verbose'          => true,
    'rack-cache.storage'          => Rack::Cache::Storage.instance,
    'rack-cache.metastore'        => 'heap:/',
    'rack-cache.entitystore'      => 'heap:/',
    'rack-cache.default_ttl'      => 0,
    'rack-cache.ignore_headers'   => ['Set-Cookie'],
    'rack-cache.private_headers'  => ['Authorization', 'Cookie'],
    'rack-cache.allow_reload'     => false,
    'rack-cache.allow_revalidate' => false,
    'rack-cache.use_native_ttl'   => false,
    'rack-cache.fault_tolerant'   => false,
  }
  self.options = options
end

def option_name(key)

def option_name(key)
  case key
  when Symbol ; "rack-cache.#{key}"
  when String ; key
  else raise ArgumentError
  end
end

def options

the Rack environment before each request is processed.
Rack environment Hash. The default values Hash is merged in underneath
request), this is a default values Hash. During a request, this is the
The underlying options Hash. During initialization (or outside of a
def options
  @env || @default_options
end

def options=(hash={})

Set multiple options.
def options=(hash={})
  hash.each { |key,value| write_option(key, value) }
end

def read_option(key)

def read_option(key)
  options[option_name(key)]
end

def set(option, value=self, &block)

the #set method were called on each.
which case each key/value pair is merged into the environment as if
exactly as specified. The +option+ argument may also be a Hash in
Environment as "rack-cache.option". When +option+ is a String, it
Set an option. When +option+ is a Symbol, it is set in the Rack
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

def write_option(key, value)

def write_option(key, value)
  options[option_name(key)] = value
end