Class: GoodData::Model::SchemaBlueprint
- Defined in:
- lib/gooddata/models/blueprint/schema_blueprint.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#project_blueprint ⇒ Object
Returns the value of attribute project_blueprint.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Compares two blueprints.
-
#anchor ⇒ GoodData::Model::AnchorBlueprintField
Returns anchor.
-
#anchor? ⇒ Boolean
Returns true if anchor is present.
-
#attributes(_id = :all, _options = {}) ⇒ Array<GoodData::Model::AttributeBlueprintField>
Returns list of all attributes defined on the schema.
-
#attributes_and_anchors ⇒ Array<GoodData::Model::AnchorBlueprintField | GoodData::Model::AttributeBlueprintField>
Returns list of attributes and anchor.
-
#breaks ⇒ Array<GoodData::Model::AnchorBlueprintField | GoodData::Model::AttributeBlueprintField>
Returns list of attributes that are broken by attributes in this dataset.
-
#bridges ⇒ Array<GoodData::Model::BridgeBlueprintField>
Returns list of all bridges defined on the schema.
-
#broken_by ⇒ Array<GoodData::Model::BlueprintField>
Returns list of attributes that can break facts in a given dataset.
-
#facts(_id = :all, _options = {}) ⇒ Array<GoodData::Model::FactBlueprintField>
Returns list of all facts defined on the schema.
-
#fields ⇒ Array<GoodData::Model::BlueprintField>
Returns list of all fields defined on the schema.
-
#find_dataset(dataset, options = {}) ⇒ GoodData::Model::DatasetBlueprint
Relays request on finding a dataset in the associated project blueprint.
-
#id ⇒ String
Returns id of the schema.
-
#initialize(dim, blueprint) ⇒ SchemaBlueprint
constructor
A new instance of SchemaBlueprint.
-
#labels(_id = :all, _options = {}) ⇒ Array<GoodData::Model::LabelBlueprintField>
Returns list of all labels defined on the schema.
-
#referenced_by ⇒ Array<GoodData::Model::SchemaBlueprint>
Returns dataset that are referencing this dataset (directly through references not transitively).
-
#references ⇒ Array<GoodData::Model::ReferenceBlueprintField>
Returns list of all references defined on the schema.
-
#referencing ⇒ Array<GoodData::Model::SchemaBlueprint>
Returns dataset that are referenced by this dataset (directly through references not transitively).
-
#title ⇒ String
Returns title of the dataset.
- #to_hash ⇒ Object
-
#valid? ⇒ Boolean
Validates the blueprint and returns true if model is valid.
-
#validate ⇒ Array<Hash>
Validates the blueprint and returns array of errors.
Constructor Details
#initialize(dim, blueprint) ⇒ SchemaBlueprint
Returns a new instance of SchemaBlueprint.
12 13 14 15 |
# File 'lib/gooddata/models/blueprint/schema_blueprint.rb', line 12 def initialize(dim, blueprint) @data = dim @project_blueprint = blueprint end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
10 11 12 |
# File 'lib/gooddata/models/blueprint/schema_blueprint.rb', line 10 def data @data end |
#project_blueprint ⇒ Object
Returns the value of attribute project_blueprint.
10 11 12 |
# File 'lib/gooddata/models/blueprint/schema_blueprint.rb', line 10 def project_blueprint @project_blueprint end |
Instance Method Details
#==(other) ⇒ Boolean
Compares two blueprints. This is done by comapring the hash represenatation. It has to be exacty identical including the order of the columns
158 159 160 |
# File 'lib/gooddata/models/blueprint/schema_blueprint.rb', line 158 def ==(other) to_hash == other.to_hash end |
#anchor ⇒ GoodData::Model::AnchorBlueprintField
Returns anchor
27 28 29 |
# File 'lib/gooddata/models/blueprint/schema_blueprint.rb', line 27 def anchor nil end |
#anchor? ⇒ Boolean
Returns true if anchor is present. Currently returns always true. Probably good to remove
20 21 22 |
# File 'lib/gooddata/models/blueprint/schema_blueprint.rb', line 20 def anchor? true end |
#attributes(_id = :all, _options = {}) ⇒ Array<GoodData::Model::AttributeBlueprintField>
Returns list of all attributes defined on the schema.
55 56 57 |
# File 'lib/gooddata/models/blueprint/schema_blueprint.rb', line 55 def attributes(_id = :all, = {}) [] end |
#attributes_and_anchors ⇒ Array<GoodData::Model::AnchorBlueprintField | GoodData::Model::AttributeBlueprintField>
Returns list of attributes and anchor.
76 77 78 |
# File 'lib/gooddata/models/blueprint/schema_blueprint.rb', line 76 def attributes_and_anchors [] end |
#breaks ⇒ Array<GoodData::Model::AnchorBlueprintField | GoodData::Model::AttributeBlueprintField>
Returns list of attributes that are broken by attributes in this dataset. This means all anchors and attributes from this dataset and the ones that are referenced by any dataset. It works transitively. Includes only anchors that have labels.
96 97 98 99 |
# File 'lib/gooddata/models/blueprint/schema_blueprint.rb', line 96 def breaks attrs = attributes_and_anchors.reject { |a| a.labels.empty? } referenced_by.empty? ? attrs : attrs + referenced_by.flat_map(&:breaks) end |
#bridges ⇒ Array<GoodData::Model::BridgeBlueprintField>
Returns list of all bridges defined on the schema.
41 42 43 |
# File 'lib/gooddata/models/blueprint/schema_blueprint.rb', line 41 def bridges [] end |
#broken_by ⇒ Array<GoodData::Model::BlueprintField>
Returns list of attributes that can break facts in a given dataset. This basically means that it is giving you all attributes from this dataset and datasets that are referenced by given dataset transitively. Includes only anchors that have labels.
86 87 88 89 |
# File 'lib/gooddata/models/blueprint/schema_blueprint.rb', line 86 def broken_by attrs = attributes_and_anchors.reject { |a| a.labels.empty? } attrs + references.map(&:dataset).flat_map(&:broken_by) end |
#facts(_id = :all, _options = {}) ⇒ Array<GoodData::Model::FactBlueprintField>
Returns list of all facts defined on the schema.
48 49 50 |
# File 'lib/gooddata/models/blueprint/schema_blueprint.rb', line 48 def facts(_id = :all, = {}) [] end |
#fields ⇒ Array<GoodData::Model::BlueprintField>
Returns list of all fields defined on the schema.
69 70 71 |
# File 'lib/gooddata/models/blueprint/schema_blueprint.rb', line 69 def fields [] end |
#find_dataset(dataset, options = {}) ⇒ GoodData::Model::DatasetBlueprint
Relays request on finding a dataset in the associated project blueprint. Used by reference fields
106 107 108 |
# File 'lib/gooddata/models/blueprint/schema_blueprint.rb', line 106 def find_dataset(dataset, = {}) project_blueprint.find_dataset(dataset, ) end |
#id ⇒ String
Returns id of the schema
113 114 115 |
# File 'lib/gooddata/models/blueprint/schema_blueprint.rb', line 113 def id data[:id] end |
#labels(_id = :all, _options = {}) ⇒ Array<GoodData::Model::LabelBlueprintField>
Returns list of all labels defined on the schema.
62 63 64 |
# File 'lib/gooddata/models/blueprint/schema_blueprint.rb', line 62 def labels(_id = :all, = {}) [] end |
#referenced_by ⇒ Array<GoodData::Model::SchemaBlueprint>
Returns dataset that are referencing this dataset (directly through references not transitively).
120 121 122 |
# File 'lib/gooddata/models/blueprint/schema_blueprint.rb', line 120 def referenced_by @project_blueprint.referencing(self) end |
#references ⇒ Array<GoodData::Model::ReferenceBlueprintField>
Returns list of all references defined on the schema.
34 35 36 |
# File 'lib/gooddata/models/blueprint/schema_blueprint.rb', line 34 def references [] end |
#referencing ⇒ Array<GoodData::Model::SchemaBlueprint>
Returns dataset that are referenced by this dataset (directly through references not transitively).
127 128 129 |
# File 'lib/gooddata/models/blueprint/schema_blueprint.rb', line 127 def referencing references.map(&:dataset) end |
#title ⇒ String
Returns title of the dataset. If it is not set up. It is generated for you based on the name which is titleized
135 136 137 |
# File 'lib/gooddata/models/blueprint/schema_blueprint.rb', line 135 def title data[:title] || GoodData::Helpers.titleize(data[:id]) end |
#to_hash ⇒ Object
162 163 164 |
# File 'lib/gooddata/models/blueprint/schema_blueprint.rb', line 162 def to_hash @data end |
#valid? ⇒ Boolean
Validates the blueprint and returns true if model is valid. False otherwise.
142 143 144 |
# File 'lib/gooddata/models/blueprint/schema_blueprint.rb', line 142 def valid? validate.empty? end |
#validate ⇒ Array<Hash>
Validates the blueprint and returns array of errors.
149 150 151 |
# File 'lib/gooddata/models/blueprint/schema_blueprint.rb', line 149 def validate fields.flat_map(&:validate) end |