Class: GoodData::Model::BlueprintField

Inherits:
Object
  • Object
show all
Defined in:
lib/gooddata/models/blueprint/blueprint_field.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, dataset) ⇒ BlueprintField

Returns a new instance of BlueprintField.



16
17
18
19
20
# File 'lib/gooddata/models/blueprint/blueprint_field.rb', line 16

def initialize(data, dataset)
  @data = GoodData::Helpers.symbolize_keys(data)
  @data[:type] = @data[:type].to_sym
  @dataset_blueprint = dataset
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_sym, *arguments, &block) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/gooddata/models/blueprint/blueprint_field.rb', line 29

def method_missing(method_sym, *arguments, &block)
  if @data.key?(method_sym)
    @data[method_sym]
  else
    super
  end
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



10
11
12
# File 'lib/gooddata/models/blueprint/blueprint_field.rb', line 10

def data
  @data
end

#dataset_blueprintObject (readonly)

Returns the value of attribute dataset_blueprint.



10
11
12
# File 'lib/gooddata/models/blueprint/blueprint_field.rb', line 10

def dataset_blueprint
  @dataset_blueprint
end

Instance Method Details

#==(other) ⇒ Object



56
57
58
59
# File 'lib/gooddata/models/blueprint/blueprint_field.rb', line 56

def ==(other)
  return false unless other.respond_to?(:data)
  @data == other.data
end

#idObject



12
13
14
# File 'lib/gooddata/models/blueprint/blueprint_field.rb', line 12

def id
  @data[:id]
end

#in_project(project) ⇒ GoodData::MdObject

Returns the md object in associated project or throws error if not present

Returns:



25
26
27
# File 'lib/gooddata/models/blueprint/blueprint_field.rb', line 25

def in_project(project)
  GoodData::MdObject[id, project: project, client: project.client]
end

#respond_to?(method_sym, *arguments, &block) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
40
41
42
43
# File 'lib/gooddata/models/blueprint/blueprint_field.rb', line 37

def respond_to?(method_sym, *arguments, &block)
  if @data.key?(method_sym)
    true
  else
    super
  end
end

#titleObject



45
46
47
# File 'lib/gooddata/models/blueprint/blueprint_field.rb', line 45

def title
  @data[:title] || GoodData::Helpers.titleize(@data[:id])
end

#validateArray

Validates the fields in the field

Returns:

  • (Array)

    returns list of the errors represented by hash structures



52
53
54
# File 'lib/gooddata/models/blueprint/blueprint_field.rb', line 52

def validate
  []
end