Project

General

Profile

Download (808 Bytes) Statistics
| Branch: | Tag: | Revision:

runcible / lib / runcible / response.rb @ e5f2394a

1
module Runcible
2
  class Response
3
    attr_accessor :rest_client_response, :parsed_body
4

    
5
    def initialize(parsed_body, rest_client_response)
6
      @rest_client_response = rest_client_response
7
      @parsed_body = parsed_body
8
    end
9

    
10
    def respond_to?(name)
11
      @parsed_body.respond_to?(name) || @rest_client_response.respond_to?(name)
12
    end
13

    
14
    def ==(other)
15
      self.parsed_body == other
16
    end
17

    
18
    def is_a?(clazz)
19
      self.parsed_body.is_a?(clazz)
20
    end
21

    
22
    def body
23
      @parsed_body
24
    end
25

    
26
    def method_missing(name, *args, &block)
27
      if @parsed_body.respond_to?(name)
28
        @parsed_body.send(name, *args, &block)
29
      elsif @rest_client_response.respond_to?(name)
30
        @rest_client_response.send(name, *args, &block)
31
      else
32
        super
33
      end
34
    end
35
  end
36
end