Sha256: 5497624b582502eae6a39707a4d203eb38751cb77eca9901e2ee3ded94bcdc07

Contents?: true

Size: 1.02 KB

Versions: 26

Compression:

Stored size: 1.02 KB

Contents

# encoding: UTF-8
#
# Copyright (c) 2010-2015 GoodData Corporation. All rights reserved.
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

module GoodData
  module Mixin
    module MdIdToUri
      IDENTIFIERS_CFG = 'instance-identifiers'

      # TODO: Add test
      def identifier_to_uri(opts = { :client => GoodData.connection, :project => GoodData.project }, *ids)
        client, project = GoodData.get_client_and_project(opts)

        uri = project.md[IDENTIFIERS_CFG]
        response = client.post uri, 'identifierToUri' => ids
        if response['identifiers'].empty?
          nil
        else
          identifiers = response['identifiers']
          ids_lookup = identifiers.reduce({}) do |a, e|
            a[e['identifier']] = e['uri']
            a
          end
          uris = ids.map { |x| ids_lookup[x] }
          uris.count == 1 ? uris.first : uris
        end
      end

      alias_method :id_to_uri, :identifier_to_uri
    end
  end
end

Version data entries

26 entries across 26 versions & 2 rubygems

Version Path
gooddata-edge-0.6.27.edge lib/gooddata/mixins/md_id_to_uri.rb
gooddata-0.6.49 lib/gooddata/mixins/md_id_to_uri.rb
gooddata-0.6.48 lib/gooddata/mixins/md_id_to_uri.rb
gooddata-0.6.47 lib/gooddata/mixins/md_id_to_uri.rb
gooddata-0.6.46 lib/gooddata/mixins/md_id_to_uri.rb
gooddata-0.6.45 lib/gooddata/mixins/md_id_to_uri.rb
gooddata-0.6.44 lib/gooddata/mixins/md_id_to_uri.rb
gooddata-0.6.43 lib/gooddata/mixins/md_id_to_uri.rb
gooddata-0.6.42 lib/gooddata/mixins/md_id_to_uri.rb
gooddata-0.6.41 lib/gooddata/mixins/md_id_to_uri.rb
gooddata-0.6.40 lib/gooddata/mixins/md_id_to_uri.rb
gooddata-0.6.39 lib/gooddata/mixins/md_id_to_uri.rb
gooddata-0.6.38 lib/gooddata/mixins/md_id_to_uri.rb
gooddata-0.6.37 lib/gooddata/mixins/md_id_to_uri.rb
gooddata-0.6.36 lib/gooddata/mixins/md_id_to_uri.rb
gooddata-0.6.35 lib/gooddata/mixins/md_id_to_uri.rb
gooddata-0.6.34 lib/gooddata/mixins/md_id_to_uri.rb
gooddata-0.6.33 lib/gooddata/mixins/md_id_to_uri.rb
gooddata-0.6.32 lib/gooddata/mixins/md_id_to_uri.rb
gooddata-0.6.31 lib/gooddata/mixins/md_id_to_uri.rb