Class: WebClient::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/web_client/response.rb

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Response

Returns a new instance of Response.



4
5
6
# File 'lib/web_client/response.rb', line 4

def initialize(response)
  @response = response
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



16
17
18
19
20
21
22
# File 'lib/web_client/response.rb', line 16

def method_missing(method, *args, &block)
  if @response.respond_to? method
    @response.send method, *args, &block
  else
    super
  end
end

Instance Method Details

#methodsObject



24
25
26
# File 'lib/web_client/response.rb', line 24

def methods
  (super | @response.methods).uniq
end

#respond_to?(method) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/web_client/response.rb', line 28

def respond_to?(method)
  super || @response.respond_to?(method)
end

#success?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/web_client/response.rb', line 12

def success?
  @response.is_a? Net::HTTPSuccess
end

#typeObject



8
9
10
# File 'lib/web_client/response.rb', line 8

def type
  @response.class
end