class GoodData::Model::SchemaBuilder

Attributes

data[RW]

Public Class Methods

create(id, options = {}, &block) click to toggle source
# File lib/gooddata/models/blueprint/schema_builder.rb, line 19
def create(id, options = {}, &block)
  pb = SchemaBuilder.new(id, options)
  block.call(pb)
  pb
end
create_from_data(blueprint) click to toggle source
# 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
new(id = nil, options = {}) click to toggle source
# File lib/gooddata/models/blueprint/schema_builder.rb, line 26
def initialize(id = nil, options = {})
  @data = {
    id: id,
    type: :dataset,
    columns: []
  }.merge(options)
end

Public Instance Methods

add_anchor(id, options = {}) click to toggle source
# File lib/gooddata/models/blueprint/schema_builder.rb, line 47
def add_anchor(id, options = {})
  add_column({ type: :anchor, id: id }.merge(options))
  self
end
add_attribute(id, options = {}) click to toggle source
# File lib/gooddata/models/blueprint/schema_builder.rb, line 52
def add_attribute(id, options = {})
  add_column({ type: :attribute, id: id }.merge(options))
  self
end
add_column(column_def) click to toggle source
# 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 = {}) click to toggle source
# File lib/gooddata/models/blueprint/schema_builder.rb, line 68
def add_date(dataset_id, options = {})
  add_column({ type: :date, dataset: dataset_id, format: GoodData::Model::DEFAULT_DATE_FORMAT }.merge(options))
end
add_fact(id, options = {}) click to toggle source
# File lib/gooddata/models/blueprint/schema_builder.rb, line 57
def add_fact(id, options = {})
  data = { type: :fact, id: id }.merge(options)
  add_column(data)
  self
end
add_label(id, options = {}) click to toggle source
# File lib/gooddata/models/blueprint/schema_builder.rb, line 63
def add_label(id, options = {})
  add_column({ type: :label, id: id }.merge(options))
  self
end
add_reference(dataset, options = {}) click to toggle source
# File lib/gooddata/models/blueprint/schema_builder.rb, line 72
def add_reference(dataset, options = {})
  add_column({ type: :reference, dataset: dataset }.merge(options))
end
columns() click to toggle source
# File lib/gooddata/models/blueprint/schema_builder.rb, line 38
def columns
  data[:columns]
end
name() click to toggle source
# File lib/gooddata/models/blueprint/schema_builder.rb, line 34
def name
  data[:name]
end
to_blueprint() click to toggle source
# File lib/gooddata/models/blueprint/schema_builder.rb, line 84
def to_blueprint
  GoodData::Model::ProjectBlueprint.new(datasets: [to_hash])
end
to_hash() click to toggle source
# File lib/gooddata/models/blueprint/schema_builder.rb, line 80
def to_hash
  data
end
to_json() click to toggle source
# File lib/gooddata/models/blueprint/schema_builder.rb, line 76
def to_json
  JSON.pretty_generate(to_hash)
end