Sha256: 324d6fad84fd8f8c63b0142076d85b1acebd0b9aa53a708ae79c055a0043cbb5

Contents?: true

Size: 441 Bytes

Versions: 6

Compression:

Stored size: 441 Bytes

Contents

module WialonApi
  class Result
    def self.process(response, block = nil)
      result = extract_result(response)
      if result.respond_to?(:each)
        block.nil? ? result : result.map(&block)
      else
        block.nil? ? result : block.call(result)
      end
    end

    def self.extract_result(response)
      if response.error
        fail WialonApi::Error.new(response)
      else
        response
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
wialon_api-0.0.6 lib/wialon_api/result.rb
wialon_api-0.0.5 lib/wialon_api/result.rb
wialon_api-0.0.4 lib/wialon_api/result.rb
wialon_api-0.0.3 lib/wialon_api/result.rb
wialon_api-0.0.2 lib/wialon_api/result.rb
wialon_api-0.0.1 lib/wialon_api/result.rb