Class: ActionDispatch::BodyProxy

Inherits:
Object
  • Object
show all
Defined in:
actionpack/lib/action_dispatch/middleware/body_proxy.rb

Instance Method Summary collapse

Constructor Details

#initialize(body, &block) ⇒ BodyProxy

Returns a new instance of BodyProxy.



4
5
6
# File 'actionpack/lib/action_dispatch/middleware/body_proxy.rb', line 4

def initialize(body, &block)
  @body, @block, @closed = body, block, false
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args, &block) ⇒ Object



26
27
28
# File 'actionpack/lib/action_dispatch/middleware/body_proxy.rb', line 26

def method_missing(*args, &block)
  @body.__send__(*args, &block)
end

Instance Method Details

#closeObject



12
13
14
15
16
17
18
19
20
# File 'actionpack/lib/action_dispatch/middleware/body_proxy.rb', line 12

def close
  return if @closed
  @closed = true
  begin
    @body.close if @body.respond_to? :close
  ensure
    @block.call
  end
end

#closed?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'actionpack/lib/action_dispatch/middleware/body_proxy.rb', line 22

def closed?
  @closed
end

#respond_to?(*args) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
# File 'actionpack/lib/action_dispatch/middleware/body_proxy.rb', line 8

def respond_to?(*args)
  super or @body.respond_to?(*args)
end