Class: GoodData::Model::SchemaBuilder
- Defined in:
- lib/gooddata/models/blueprint/schema_builder.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
Class Method Summary collapse
Instance Method Summary collapse
- #add_anchor(id, options = {}) ⇒ Object
- #add_attribute(id, options = {}) ⇒ Object
- #add_column(column_def) ⇒ Object
- #add_date(dataset_id, options = {}) ⇒ Object
- #add_fact(id, options = {}) ⇒ Object
- #add_label(id, options = {}) ⇒ Object
- #add_reference(dataset, options = {}) ⇒ Object
- #columns ⇒ Object
-
#initialize(id = nil, options = {}) ⇒ SchemaBuilder
constructor
A new instance of SchemaBuilder.
- #name ⇒ Object
- #to_blueprint ⇒ Object
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(id = nil, options = {}) ⇒ SchemaBuilder
Returns a new instance of SchemaBuilder.
26 27 28 29 30 31 32 |
# File 'lib/gooddata/models/blueprint/schema_builder.rb', line 26 def initialize(id = nil, = {}) @data = { id: id, type: :dataset, columns: [] }.merge() end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
10 11 12 |
# File 'lib/gooddata/models/blueprint/schema_builder.rb', line 10 def data @data end |
Class Method Details
.create(id, options = {}, &block) ⇒ Object
19 20 21 22 23 |
# File 'lib/gooddata/models/blueprint/schema_builder.rb', line 19 def create(id, = {}, &block) pb = SchemaBuilder.new(id, ) block.call(pb) pb end |
.create_from_data(blueprint) ⇒ Object
13 14 15 16 17 |
# File 'lib/gooddata/models/blueprint/schema_builder.rb', line 13 def create_from_data(blueprint) sc = SchemaBuilder.new sc.data = blueprint.to_hash sc end |
Instance Method Details
#add_anchor(id, options = {}) ⇒ Object
47 48 49 50 |
# File 'lib/gooddata/models/blueprint/schema_builder.rb', line 47 def add_anchor(id, = {}) add_column({ type: :anchor, id: id }.merge()) self end |
#add_attribute(id, options = {}) ⇒ Object
52 53 54 55 |
# File 'lib/gooddata/models/blueprint/schema_builder.rb', line 52 def add_attribute(id, = {}) add_column({ type: :attribute, id: id }.merge()) self end |
#add_column(column_def) ⇒ Object
42 43 44 45 |
# File 'lib/gooddata/models/blueprint/schema_builder.rb', line 42 def add_column(column_def) columns.push(column_def) self end |
#add_date(dataset_id, options = {}) ⇒ Object
68 69 70 |
# File 'lib/gooddata/models/blueprint/schema_builder.rb', line 68 def add_date(dataset_id, = {}) add_column({ type: :date, dataset: dataset_id, format: GoodData::Model::DEFAULT_DATE_FORMAT }.merge()) end |
#add_fact(id, options = {}) ⇒ Object
57 58 59 60 61 |
# File 'lib/gooddata/models/blueprint/schema_builder.rb', line 57 def add_fact(id, = {}) data = { type: :fact, id: id }.merge() add_column(data) self end |
#add_label(id, options = {}) ⇒ Object
63 64 65 66 |
# File 'lib/gooddata/models/blueprint/schema_builder.rb', line 63 def add_label(id, = {}) add_column({ type: :label, id: id }.merge()) self end |
#add_reference(dataset, options = {}) ⇒ Object
72 73 74 |
# File 'lib/gooddata/models/blueprint/schema_builder.rb', line 72 def add_reference(dataset, = {}) add_column({ type: :reference, dataset: dataset }.merge()) end |
#columns ⇒ Object
38 39 40 |
# File 'lib/gooddata/models/blueprint/schema_builder.rb', line 38 def columns data[:columns] end |
#name ⇒ Object
34 35 36 |
# File 'lib/gooddata/models/blueprint/schema_builder.rb', line 34 def name data[:name] end |
#to_blueprint ⇒ Object
84 85 86 |
# File 'lib/gooddata/models/blueprint/schema_builder.rb', line 84 def to_blueprint GoodData::Model::ProjectBlueprint.new(datasets: [to_hash]) end |
#to_hash ⇒ Object
80 81 82 |
# File 'lib/gooddata/models/blueprint/schema_builder.rb', line 80 def to_hash data end |
#to_json ⇒ Object
76 77 78 |
# File 'lib/gooddata/models/blueprint/schema_builder.rb', line 76 def to_json JSON.pretty_generate(to_hash) end |