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



99
100
101
# File 'lib/httpx/adapters/faraday.rb', line 99

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



127
128
129
130
131
132
133
# File 'lib/httpx/adapters/faraday.rb', line 127

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.



97
98
99
# File 'lib/httpx/adapters/faraday.rb', line 97

def env
  @env
end

Instance Method Details

#on_complete(&blk) ⇒ Object



114
115
116
117
118
119
120
121
# File 'lib/httpx/adapters/faraday.rb', line 114

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

#on_response(&blk) ⇒ Object



103
104
105
106
107
108
109
110
111
112
# File 'lib/httpx/adapters/faraday.rb', line 103

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



123
124
125
# File 'lib/httpx/adapters/faraday.rb', line 123

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