Sha256: 8c1b4a485b2b6e5d107e01883c14ab30b1e5721009f8681c7436ccff41de353d

Contents?: true

Size: 1.13 KB

Versions: 10

Compression:

Stored size: 1.13 KB

Contents

# 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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
gooddata-0.6.20 lib/gooddata/connection.rb
gooddata-0.6.19 lib/gooddata/connection.rb
gooddata-0.6.18 lib/gooddata/connection.rb
gooddata-0.6.17 lib/gooddata/connection.rb
gooddata-0.6.16 lib/gooddata/connection.rb
gooddata-0.6.15 lib/gooddata/connection.rb
gooddata-0.6.14 lib/gooddata/connection.rb
gooddata-0.6.13 lib/gooddata/connection.rb
gooddata-0.6.12 lib/gooddata/connection.rb
gooddata-0.6.11 lib/gooddata/connection.rb