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.



95
96
97
# File 'lib/httpx/adapters/faraday.rb', line 95

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



123
124
125
126
127
128
129
# File 'lib/httpx/adapters/faraday.rb', line 123

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.



93
94
95
# File 'lib/httpx/adapters/faraday.rb', line 93

def env
  @env
end

Instance Method Details

#on_complete(&blk) ⇒ Object



110
111
112
113
114
115
116
117
# File 'lib/httpx/adapters/faraday.rb', line 110

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

#on_response(&blk) ⇒ Object



99
100
101
102
103
104
105
106
107
108
# File 'lib/httpx/adapters/faraday.rb', line 99

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)


119
120
121
# File 'lib/httpx/adapters/faraday.rb', line 119

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