Module: Ur::Middleware

Included in:
FaradayMiddleware, RackMiddleware
Defined in:
lib/ur/middleware.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



11
12
13
# File 'lib/ur/middleware.rb', line 11

def app
  @app
end

#optionsObject (readonly)

Returns the value of attribute options.



12
13
14
# File 'lib/ur/middleware.rb', line 12

def options
  @options
end

Instance Method Details

#begin_request(ur) ⇒ Object



14
15
16
# File 'lib/ur/middleware.rb', line 14

def begin_request(ur)
  ur..begin!
end

#finish_request(ur) ⇒ Object



18
19
20
21
# File 'lib/ur/middleware.rb', line 18

def finish_request(ur)
  ur.logger_tags(@options[:logger])
  ur..finish!
end

#initialize(app, options = {}) ⇒ Object



7
8
9
10
# File 'lib/ur/middleware.rb', line 7

def initialize(app, options = {})
  @app = app
  @options = options
end

#invoke_callback(name, *a, &b) ⇒ Object



23
24
25
26
27
# File 'lib/ur/middleware.rb', line 23

def invoke_callback(name, *a, &b)
  if @options[name]
    @options[name].call(*a, &b)
  end
end