Class: Faraday::Adapter::HTTPX::ParallelManager::ResponseHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/httpx/adapters/faraday.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env) ⇒ ResponseHandler

Returns a new instance of ResponseHandler.



58
59
60
# File 'lib/httpx/adapters/faraday.rb', line 58

def initialize(env)
  @env = env
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &blk) ⇒ Object



86
87
88
89
90
91
92
# File 'lib/httpx/adapters/faraday.rb', line 86

def method_missing(meth, *args, &blk)
  if @env && @env.respond_to?(meth)
    @env.__send__(meth, *args, &blk)
  else
    super
  end
end

Instance Attribute Details

#envObject (readonly)

Returns the value of attribute env.



56
57
58
# File 'lib/httpx/adapters/faraday.rb', line 56

def env
  @env
end

Instance Method Details

#on_complete(&blk) ⇒ Object



73
74
75
76
77
78
79
80
# File 'lib/httpx/adapters/faraday.rb', line 73

def on_complete(&blk)
  if block_given?
    @on_complete = blk
    self
  else
    @on_complete
  end
end

#on_response(&blk) ⇒ Object



62
63
64
65
66
67
68
69
70
71
# File 'lib/httpx/adapters/faraday.rb', line 62

def on_response(&blk)
  if block_given?
    @on_response = lambda do |response|
      blk.call(response)
    end
    self
  else
    @on_response
  end
end

#respond_to_missing?(meth) ⇒ Boolean

Returns:

  • (Boolean)


82
83
84
# File 'lib/httpx/adapters/faraday.rb', line 82

def respond_to_missing?(meth)
  @env.respond_to?(meth)
end