Class: Expedition::Response

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(normalized, raw) ⇒ Response

Returns a new instance of Response.



20
21
22
23
24
# File 'lib/expedition/response.rb', line 20

def initialize(normalized, raw)
  @body   = normalized
  @raw    = raw
  @status = Status.new(raw['STATUS'])
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *arguments, &block) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/expedition/response.rb', line 35

def method_missing(method_name, *arguments, &block)
  if respond_to_missing?(method_name)
    body.send(method_name, *arguments, &block)
  else
    super
  end
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



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

def body
  @body
end

#rawObject (readonly)

Returns the value of attribute raw.



10
11
12
# File 'lib/expedition/response.rb', line 10

def raw
  @raw
end

#statusObject (readonly)

Returns the value of attribute status.



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

def status
  @status
end

Class Method Details

.parse(raw) ⇒ Object



14
15
16
17
18
# File 'lib/expedition/response.rb', line 14

def self.parse(raw)
  normalized = normalize(raw)
  normalized = yield normalized if block_given?
  new(normalized, raw)
end

Instance Method Details

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/expedition/response.rb', line 31

def respond_to_missing?(method_name, include_private = false)
  body.respond_to?(method_name) || super
end