Sha256: 9bf71266130f2aa0141b068b10864151d4ec0f91009959eb7eb6c797c06601c1

Contents?: true

Size: 808 Bytes

Versions: 1

Compression:

Stored size: 808 Bytes

Contents

module Runcible
  class Response
    attr_accessor :rest_client_response, :parsed_body

    def initialize(parsed_body, rest_client_response)
      @rest_client_response = rest_client_response
      @parsed_body = parsed_body
    end

    def respond_to?(name)
      @parsed_body.respond_to?(name) || @rest_client_response.respond_to?(name)
    end

    def ==(other)
      self.parsed_body == other
    end

    def is_a?(clazz)
      self.parsed_body.is_a?(clazz)
    end

    def body
      @parsed_body
    end

    def method_missing(name, *args, &block)
      if @parsed_body.respond_to?(name)
        @parsed_body.send(name, *args, &block)
      elsif @rest_client_response.respond_to?(name)
        @rest_client_response.send(name, *args, &block)
      else
        super
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
runcible-2.0.0 lib/runcible/response.rb