Class: GoodData::Model::AttributeBlueprintField
- Inherits:
-
BlueprintField
- Object
- BlueprintField
- GoodData::Model::AttributeBlueprintField
- Defined in:
- lib/gooddata/models/blueprint/attribute_field.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from BlueprintField
Instance Method Summary collapse
-
#labels ⇒ Array
Returns list of labels on the attribute.
-
#reference_label ⇒ Array<GoodData::Model::LabelBlueprintField>
Returns label that is considered referencing.
-
#validate ⇒ Array
Validates the fields in the attribute.
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
#labels ⇒ Array
Returns list of labels on the attribute. There has to be always at least one attribute
24 25 26 |
# File 'lib/gooddata/models/blueprint/attribute_field.rb', line 24 def labels @dataset_blueprint.labels_for_attribute(self) end |
#reference_label ⇒ Array<GoodData::Model::LabelBlueprintField>
Returns label that is considered referencing. It is either first one or the one marked with reference_label: true in blueprint
16 17 18 19 |
# File 'lib/gooddata/models/blueprint/attribute_field.rb', line 16 def reference_label reference_label = labels.find { |label| label.respond_to?(:reference_label) && label.reference_label == true } reference_label || labels.first end |
#validate ⇒ Array
Validates the fields in the attribute
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/gooddata/models/blueprint/attribute_field.rb', line 31 def validate errors = validate_presence_of(:id).map do |e| { type: :error, message: "Field \"#{e}\" is not defined or empty for attribute \"#{id}\"" } end if labels.select(&:reference_label?).count > 1 errors << { type: :error, message: "Anchor \"#{id}\" can have only one label with reference_label field set to true" } end errors end |