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
23
24
25
26
27
# File 'lib/mnemosyne/middleware/rack.rb', line 19

def method_missing(*args)
  super if args.first && args.first.to_s == 'to_ary'

  if block_given?
    @body.__send__(*args, &Proc.new)
  else
    @body.__send__(*args)
  end
end

Instance Method Details

#closeObject



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/mnemosyne/middleware/rack.rb', line 29

def close
  return if @closed

  @closed = true

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

#closed?Boolean

Returns:

  • (Boolean)


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

def closed?
  @closed
end

#each(*args) ⇒ Object



45
46
47
48
49
50
# File 'lib/mnemosyne/middleware/rack.rb', line 45

def each(*args)
  @body.each(*args, &Proc.new)
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