Sha256: b54b295e6e9e8d14746470daf9373fa8f116383369cc96606a242e703a40b4e9

Contents?: true

Size: 870 Bytes

Versions: 19

Compression:

Stored size: 870 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 to_hash
      self.parsed_body.try(:to_hash)
    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

19 entries across 19 versions & 1 rubygems

Version Path
runcible-2.13.1 lib/runcible/response.rb
runcible-2.13.0 lib/runcible/response.rb
runcible-2.12.1 lib/runcible/response.rb
runcible-2.12.0 lib/runcible/response.rb
runcible-2.11.1 lib/runcible/response.rb
runcible-2.11.0 lib/runcible/response.rb
runcible-2.10.1 lib/runcible/response.rb
runcible-2.10.0 lib/runcible/response.rb
runcible-2.9.0 lib/runcible/response.rb
runcible-2.8.1 lib/runcible/response.rb
runcible-2.8.0 lib/runcible/response.rb
runcible-2.7.0 lib/runcible/response.rb
runcible-2.6.0 lib/runcible/response.rb
runcible-2.5.0 lib/runcible/response.rb
runcible-2.4.0 lib/runcible/response.rb
runcible-2.3.0 lib/runcible/response.rb
runcible-2.2.0 lib/runcible/response.rb
runcible-2.1.0 lib/runcible/response.rb
runcible-2.0.1 lib/runcible/response.rb