Sha256: 5d2480e735d6f408b4f0a888f560bc2fc7a9d12eee440b2930e7c508ca754959

Contents?: true

Size: 494 Bytes

Versions: 7

Compression:

Stored size: 494 Bytes

Contents

# frozen_string_literal: true

module Meroku
  # Logic related to making rest api calls to backend rails server
  module ResponseHandler
    def process_error(result)
      raise Meroku::Error, JSON.parse(result).dig('errors') \
        if JSON.parse(result).dig('errors')
    end

    def process_success(result)
      id = JSON.parse(result).dig('data', 'id')
      if id
        yield(result) if block_given?
        puts "OK [#{id}]"
      end
      raise Meroku::Success
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
meroku-2.0.31 lib/meroku/response_handler.rb
meroku-2.0.30 lib/meroku/response_handler.rb
meroku-2.0.29 lib/meroku/response_handler.rb
meroku-2.0.28 lib/meroku/response_handler.rb
meroku-2.0.27 lib/meroku/response_handler.rb
meroku-2.0.26 lib/meroku/response_handler.rb
meroku-2.0.25 lib/meroku/response_handler.rb