Class: Deflectable::Watcher

Inherits:
Object
  • Object
show all
Defined in:
lib/deflectable/watcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, build_options = {}, &block) ⇒ Watcher

Returns a new instance of Watcher.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/deflectable/watcher.rb', line 6

def initialize(app, build_options={}, &block)
  @app = app
  @filtering = nil
  @options = {
    :log => false,
    :logger => nil,
    :log_format => 'deflect(%s): %s',
    :log_date_format => '%m/%d/%Y',
    :whitelist => [],
    :blacklist => [],
    :config_path => nil,
  }.merge(build_options)
  @options = @options.merge(block.call) if block_given?
  configure_check!
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



4
5
6
# File 'lib/deflectable/watcher.rb', line 4

def options
  @options
end

Instance Method Details

#call(env) ⇒ Object



22
23
24
25
26
# File 'lib/deflectable/watcher.rb', line 22

def call(env)
  return reject!(env) unless permit?(env)
  status, headers, body = @app.call(env)
  [status, headers, body]
end