Sha256: 8ee33800772027c43eb6cd82f718a26f48e891f74bea3b02a07621eab0afac91

Contents?: true

Size: 859 Bytes

Versions: 5

Compression:

Stored size: 859 Bytes

Contents

module Omniship #:nodoc:
  class Error < StandardError
  end

  class ResponseError < Error
    attr_reader :response

    def initialize(response = nil)
      if response.is_a? Response
        super(response.message)
        @response = response
      else
        super(response)
      end
    end
  end

  class Response

    attr_reader :params
    attr_reader :message
    attr_reader :test
    attr_reader :xml
    attr_reader :request

    def initialize(success, message, params = {}, options = {})
      @success, @message, @params = success, message, params.stringify_keys
      @test = options[:test] || false
      @xml = options[:xml]
      @request = options[:request]
      raise ResponseError.new(self) unless success
    end

    def success?
      @success ? true : false
    end

    def test?
      @test ? true : false
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
omniship-0.4.7 lib/omniship/response.rb
omniship-0.4.6 lib/omniship/response.rb
omniship-0.4.5 lib/omniship/response.rb
omniship-0.4.1 lib/omniship/response.rb
omniship-0.4.0 lib/omniship/response.rb