Sha256: 45db756ecb8c7f34aa7535c23944f6cc6259d67c3bae7471b1f6938d2246dbdc
Contents?: true
Size: 1.25 KB
Versions: 3
Compression:
Stored size: 1.25 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 = opts[:client] fail ArgumentError, 'No :client specified' if client.nil? p = opts[:project] fail ArgumentError, 'No :project specified' if p.nil? project = GoodData::Project[p, opts] fail ArgumentError, 'Wrong :project specified' if project.nil? 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
gooddata-0.6.24 | lib/gooddata/mixins/md_id_to_uri.rb |
gooddata-0.6.23 | lib/gooddata/mixins/md_id_to_uri.rb |
gooddata-0.6.22 | lib/gooddata/mixins/md_id_to_uri.rb |