Class: GoodData::Model::AnchorBlueprintField

Inherits:
AttributeBlueprintField show all
Defined in:
lib/gooddata/models/blueprint/anchor_field.rb

Instance Attribute Summary

Attributes inherited from BlueprintField

#data, #dataset_blueprint

Instance Method Summary collapse

Methods inherited from AttributeBlueprintField

#reference_label

Methods inherited from BlueprintField

#==, #id, #in_project, #initialize, #method_missing, #respond_to_missing?, #title

Constructor Details

This class inherits a constructor from GoodData::Model::BlueprintField

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class GoodData::Model::BlueprintField

Instance Method Details

#anchor?Boolean

Returns true if it is an anchor

Returns:

  • (Boolean)

    returns true



15
16
17
# File 'lib/gooddata/models/blueprint/anchor_field.rb', line 15

def anchor?
  true
end

#grainArray<Hash>

Returns grain definition if the anchor has it. Nil otherwise

Returns:

  • (Array<Hash>)

    Returns grain definitions



29
30
31
# File 'lib/gooddata/models/blueprint/anchor_field.rb', line 29

def grain
  data[:grain]
end

#grain?Boolean

Returns true if grain is defined

Returns:

  • (Boolean)

    Returns true if grain is defined on the anchor



22
23
24
# File 'lib/gooddata/models/blueprint/anchor_field.rb', line 22

def grain?
  !data[:grain].nil?
end

#labelsArray<GoodData::Model::LabelBlueprintField>

Returns labels for anchor or empty array if there are none

Returns:



50
51
52
# File 'lib/gooddata/models/blueprint/anchor_field.rb', line 50

def labels
  dataset_blueprint.labels_for_attribute(self)
end

#remove!GoodData::Model::ProjectBlueprint

Alias for strip!. Removes all the labels from the anchor. This is a typical operation that people want to perform

Returns:



43
44
45
# File 'lib/gooddata/models/blueprint/anchor_field.rb', line 43

def remove!
  strip!
end

#strip!GoodData::Model::ProjectBlueprint

Removes all the labels from the anchor. This is a typical operation that people want to perform

Returns:



36
37
38
# File 'lib/gooddata/models/blueprint/anchor_field.rb', line 36

def strip!
  dataset_blueprint.strip_anchor!
end

#validateArray<Hash>

Validates the field for presence of mandatory fields

Returns:

  • (Array<Hash>)

    Returns list of errors as hashes



57
58
59
60
61
62
# File 'lib/gooddata/models/blueprint/anchor_field.rb', line 57

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