Class: InfluxReporter::BodyProxy

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

Instance Method Summary collapse

Constructor Details

#initialize(body, &block) ⇒ BodyProxy

Returns a new instance of BodyProxy.



33
34
35
36
37
# File 'lib/influx_reporter/middleware.rb', line 33

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(*args, &block) ⇒ Object



59
60
61
# File 'lib/influx_reporter/middleware.rb', line 59

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

Instance Method Details

#closeObject



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/influx_reporter/middleware.rb', line 43

def close
  return if closed?

  @closed = true

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

#closed?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/influx_reporter/middleware.rb', line 55

def closed?
  @closed
end

#respond_to?(*args) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/influx_reporter/middleware.rb', line 39

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