# encoding: UTF-8 require_relative 'core/logging' require_relative 'rest/rest' module GoodData class << self # Returns the active GoodData connection earlier initialized via GoodData.connect call # # @see GoodData.connect def connection # TODO: Remove this after successful rest-factory transition Rest::Client.connection # || fail('Please authenticate with GoodData.connect first') end alias_method :client, :connection # Connect to the GoodData API # # @param options # @param second_options # @param third_options # def connect(options = nil, second_options = nil, third_options = {}) Rest::Client.connect(options, second_options, third_options) end # Disconnect (logout) if logged in def disconnect Rest::Client.disconnect end def with_connection(options = nil, second_options = nil, third_options = {}, &bl) connection = connect(options, second_options, third_options) bl.call(connection) rescue Exception => e # rubocop:disable RescueException puts e.message raise e ensure disconnect end end end