Sha256: 3164a1fb37f24dccdc196a7816da63c7fd6d53744d6d7a12bf67dc3eeaa4bc02

Contents?: true

Size: 1.02 KB

Versions: 29

Compression:

Stored size: 1.02 KB

Contents

module GoodData
  class Links
    attr_reader :data

    def initialize(items)
      @data = {}
      items.values[0]['links'].each do |item|
        category = item['category']
        if @data[category] then
          if @data[category]['category'] == category then
            @data[category] = { @data[category]['identifier'] => @data[category] }
          end
          @data[category][item['identifier']] = item
        else
          @data[category] = item
        end
      end
    end

    def links(category, identifier = nil)
      return Links.new(GoodData.get(self[category])) unless identifier
      Links.new GoodData.get(get(category, identifier))
    end

    def [](category)
      return @data[category]['link'] if @data[category] && @data[category]['link']
      @data[category]
    end

    def is_unique?(category)
      @data[category]['link'].is_a? String
    end

    def is_ambiguous?(category)
      !is_unique?(category)
    end

    def get(category, identifier)
      self[category][identifier]
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
gooddata-0.6.0.pre11 lib/gooddata/models/links.rb
gooddata-0.6.0.pre10 lib/gooddata/models/links.rb
gooddata-0.6.0.pre9 lib/gooddata/models/links.rb
gooddata-0.6.0.pre8 lib/gooddata/models/links.rb
gooddata-0.6.0.pre7 lib/gooddata/models/links.rb
gooddata-0.6.0.pre6 lib/gooddata/models/links.rb
gooddata-0.6.0.pre5 lib/gooddata/models/links.rb
gooddata-0.6.0.pre4 lib/gooddata/models/links.rb
gooddata-0.6.0.pre3 lib/gooddata/models/links.rb
gooddata-0.6.0.pre2 lib/gooddata/models/links.rb
gooddata-0.5.16 lib/gooddata/models/links.rb
gooddata-0.5.15 lib/gooddata/models/links.rb
gooddata-0.5.14 lib/gooddata/models/links.rb
gooddata-0.5.13 lib/gooddata/models/links.rb
gooddata-0.5.12 lib/gooddata/models/links.rb
gooddata-0.5.11 lib/gooddata/models/links.rb
gooddata-0.5.10 lib/gooddata/models/links.rb
gooddata-0.5.9 lib/gooddata/models/links.rb
gooddata-0.5.8 lib/gooddata/models/links.rb
gooddata-0.5.7 lib/gooddata/models/links.rb