Module: Rack::Insight::Options

Included in:
App
Defined in:
lib/rack/insight/options.rb

Instance Method Summary collapse

Instance Method Details

#optionsObject

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.



25
26
27
# File 'lib/rack/insight/options.rb', line 25

def options
  @env || @default_options
end

#options=(hash = {}) ⇒ Object

Set multiple options.



30
31
32
# File 'lib/rack/insight/options.rb', line 30

def options=(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.



39
40
41
42
43
44
45
46
47
# File 'lib/rack/insight/options.rb', line 39

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