Sha256: 487348f642c8b660716ed0072aee5413152641aecc3df206a5e91db96f20e8c6

Contents?: true

Size: 1.91 KB

Versions: 77

Compression:

Stored size: 1.91 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 'attribute_field'

module GoodData
  module Model
    class AnchorBlueprintField < AttributeBlueprintField
      # Returns true if it is an anchor
      #
      # @return [Boolean] returns true
      def anchor?
        true
      end

      # Returns true if grain is defined
      #
      # @return [Boolean] Returns true if grain is defined on the anchor
      def grain?
        !data[:grain].nil?
      end

      # Returns grain definition if the anchor has it. Nil otherwise
      #
      # @return [Array<Hash>] Returns grain definitions
      def grain
        data[:grain]
      end

      # Removes all the labels from the anchor. This is a typical operation that people want to perform
      #
      # @return [GoodData::Model::ProjectBlueprint] Returns changed blueprint
      def strip!
        dataset_blueprint.strip_anchor!
      end

      # Alias for strip!. Removes all the labels from the anchor. This is a typical operation that people want to perform
      #
      # @return [GoodData::Model::ProjectBlueprint] Returns changed blueprint
      def remove!
        strip!
      end

      # Returns labels for anchor or empty array if there are none
      #
      # @return [Array<GoodData::Model::LabelBlueprintField>] Returns list of labels
      def labels
        dataset_blueprint.labels_for_attribute(self)
      end

      # Validates the field for presence of mandatory fields
      #
      # @return [Array<Hash>] Returns list of errors as hashes
      def validate
        errors = super
        errors.concat(validate_presence_of(:id).map do |e|
          { type: :error, message: "Field \"#{e}\" is not defined or empty for anchor \"#{id}\"" }
        end)
      end
    end
  end
end

Version data entries

77 entries across 77 versions & 1 rubygems

Version Path
gooddata-2.1.0-java lib/gooddata/models/blueprint/anchor_field.rb
gooddata-2.1.0 lib/gooddata/models/blueprint/anchor_field.rb
gooddata-2.0.1-java lib/gooddata/models/blueprint/anchor_field.rb
gooddata-2.0.1 lib/gooddata/models/blueprint/anchor_field.rb
gooddata-2.0.0-java lib/gooddata/models/blueprint/anchor_field.rb
gooddata-2.0.0 lib/gooddata/models/blueprint/anchor_field.rb
gooddata-1.3.6-java lib/gooddata/models/blueprint/anchor_field.rb
gooddata-1.3.6 lib/gooddata/models/blueprint/anchor_field.rb
gooddata-1.3.5-java lib/gooddata/models/blueprint/anchor_field.rb
gooddata-1.3.5 lib/gooddata/models/blueprint/anchor_field.rb
gooddata-1.3.4-java lib/gooddata/models/blueprint/anchor_field.rb
gooddata-1.3.4 lib/gooddata/models/blueprint/anchor_field.rb
gooddata-1.3.3-java lib/gooddata/models/blueprint/anchor_field.rb
gooddata-1.3.3 lib/gooddata/models/blueprint/anchor_field.rb
gooddata-1.3.2-java lib/gooddata/models/blueprint/anchor_field.rb
gooddata-1.3.2 lib/gooddata/models/blueprint/anchor_field.rb
gooddata-1.3.1-java lib/gooddata/models/blueprint/anchor_field.rb
gooddata-1.3.1 lib/gooddata/models/blueprint/anchor_field.rb
gooddata-1.3.0-java lib/gooddata/models/blueprint/anchor_field.rb
gooddata-1.3.0 lib/gooddata/models/blueprint/anchor_field.rb