Sha256: 0907dcaed1d8ef21566a6ac8548c8de77fb5d342bf0e666d853140e2969157d3

Contents?: true

Size: 473 Bytes

Versions: 2

Compression:

Stored size: 473 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.respond_to?(:error) && response.error
        fail WialonApi::Error.new(response)
      else
        response
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wialon_api-0.0.8 lib/wialon_api/result.rb
wialon_api-0.0.7 lib/wialon_api/result.rb