Class: Mnemosyne::Middleware::Rack::Proxy

Inherits:
Object
  • Object
show all
Defined in:
lib/mnemosyne/middleware/rack.rb

Instance Method Summary collapse

Constructor Details

#initialize(body, trace) ⇒ Proxy

Returns a new instance of Proxy.



7
8
9
10
11
# File 'lib/mnemosyne/middleware/rack.rb', line 7

def initialize(body, trace)
  @body = body
  @trace = trace
  @closed = false
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args) ⇒ Object



19
20
21
22
# File 'lib/mnemosyne/middleware/rack.rb', line 19

def method_missing(*args, &)
  super if args.first && args.first.to_s == 'to_ary'
  @body.__send__(*args, &)
end

Instance Method Details

#closeObject



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/mnemosyne/middleware/rack.rb', line 24

def close
  return if @closed

  @closed = true

  begin
    @body.close if @body.respond_to? :close
  ensure
    _submit_trace
  end
end

#closed?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/mnemosyne/middleware/rack.rb', line 36

def closed?
  @closed
end

#eachObject



40
41
42
43
44
45
# File 'lib/mnemosyne/middleware/rack.rb', line 40

def each(...)
  @body.each(...)
rescue StandardError, LoadError, SyntaxError => e
  @trace.attach_error(e)
  raise
end

#respond_to_missing?(*args) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
16
17
# File 'lib/mnemosyne/middleware/rack.rb', line 13

def respond_to_missing?(*args)
  return false if args.first && args.first.to_s == 'to_ary'

  @body.respond_to?(*args)
end