Sha256: 22002174532ff6451388cb0877c4da3860a6a310332f3f788901f5b9edef56ac

Contents?: true

Size: 1.89 KB

Versions: 75

Compression:

Stored size: 1.89 KB

Contents

# encoding: UTF-8
#
# Copyright (c) 2010-2017 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.

require_relative '../metadata'
require_relative '../../mixins/is_dimension'
require_relative 'metadata'

module GoodData
  class Dimension < GoodData::MdObject
    include Mixin::IsDimension

    class << self
      # Method intended to get all objects of that type in a specified project
      #
      # @param options [Hash] the options hash
      # @option options [Boolean] :full if passed true the subclass can
      # decide to pull in full objects. This is desirable from the usability
      # POV but unfortunately has negative impact on performance so it is
      # not the default.
      # @return [Array<GoodData::MdObject> | Array<Hash>] Return the appropriate metadata objects or their representation
      def all(options = { :client => GoodData.connection, :project => GoodData.project })
        query('dimension', Dimension, options)
      end

      # Returns a Project object identified by given string
      # The following identifiers are accepted
      #  - /gdc/md/<id>
      #  - /gdc/projects/<id>
      #  - <id>
      #
      def [](id, opts = { client: GoodData.connection })
        return id if id.instance_of?(GoodData::Dimension) || id.respond_to?(:dimension?) && id.dimension?

        if id == :all
          Dimension.all({ client: GoodData.connection }.merge(opts))
        else
          uri = id

          c = client(opts)
          fail ArgumentError, 'No :client specified' if c.nil?

          response = c.get(uri)
          c.factory.create(Dimension, response)
        end
      end
    end

    def attributes
      content['attributes'].map do |attribute|
        client.create(Attribute, { 'attribute' => attribute }, project: project)
      end
    end
  end
end

Version data entries

75 entries across 75 versions & 1 rubygems

Version Path
gooddata-2.1.10-java lib/gooddata/models/metadata/dimension.rb
gooddata-2.1.10 lib/gooddata/models/metadata/dimension.rb
gooddata-2.1.9-java lib/gooddata/models/metadata/dimension.rb
gooddata-2.1.9 lib/gooddata/models/metadata/dimension.rb
gooddata-2.1.8-java lib/gooddata/models/metadata/dimension.rb
gooddata-2.1.8 lib/gooddata/models/metadata/dimension.rb
gooddata-2.1.7-java lib/gooddata/models/metadata/dimension.rb
gooddata-2.1.7 lib/gooddata/models/metadata/dimension.rb
gooddata-2.1.6-java lib/gooddata/models/metadata/dimension.rb
gooddata-2.1.6 lib/gooddata/models/metadata/dimension.rb
gooddata-2.1.5-java lib/gooddata/models/metadata/dimension.rb
gooddata-2.1.5 lib/gooddata/models/metadata/dimension.rb
gooddata-2.1.4-java lib/gooddata/models/metadata/dimension.rb
gooddata-2.1.4 lib/gooddata/models/metadata/dimension.rb
gooddata-2.1.3-java lib/gooddata/models/metadata/dimension.rb
gooddata-2.1.3 lib/gooddata/models/metadata/dimension.rb
gooddata-2.1.2-java lib/gooddata/models/metadata/dimension.rb
gooddata-2.1.2 lib/gooddata/models/metadata/dimension.rb
gooddata-2.1.1-java lib/gooddata/models/metadata/dimension.rb
gooddata-2.1.1 lib/gooddata/models/metadata/dimension.rb