Class: EcsLogging::BodyProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/ecs_logging/body_proxy.rb

Instance Method Summary collapse

Constructor Details

#initialize(body, &block) ⇒ BodyProxy

Returns a new instance of BodyProxy.



22
23
24
25
26
# File 'lib/ecs_logging/body_proxy.rb', line 22

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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



32
33
34
# File 'lib/ecs_logging/body_proxy.rb', line 32

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

Instance Method Details

#closeObject



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/ecs_logging/body_proxy.rb', line 36

def close
  return if closed?

  @closed = true

  begin
    @body.close if @body.respond_to?(:close)
  ensure
    @block.call
  end
end

#closed?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/ecs_logging/body_proxy.rb', line 48

def closed?
  @closed
end

#respond_to_missing?(name, include_all = false) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/ecs_logging/body_proxy.rb', line 28

def respond_to_missing?(name, include_all = false)
  super || @body.respond_to?(name, include_all)
end