class GoodData::Variable
Public Class Methods
Method intended to get all objects of that type in a specified project
@param options [Hash] the options hash @option options [Boolean] :full if passed true the subclass can decide to pull in full objects. This is desirable from the usability POV but unfortunately has negative impact on performance so it is not the default @return [Array<GoodData::MdObject> | Array<Hash>] Return the appropriate metadata objects or their representation
# File lib/gooddata/models/metadata/variable.rb, line 22 def all(options = { :client => GoodData.connection, :project => GoodData.project }) query('prompt', Variable, options) end
# File lib/gooddata/models/metadata/variable.rb, line 26 def create(data, options = { :client => GoodData.connection, :project => GoodData.project }) title = data[:title] project = options[:project] c = client(options) attribute = project.attributes(data[:attribute]) payload = { 'prompt' => { 'content' => { 'attribute' => attribute.uri, 'type' => 'filter' }, 'meta' => { 'tags' => '', 'deprecated' => '0', 'summary' => '', 'title' => title, 'category' => 'prompt' } } } c.create(self, payload, project: project) end
Public Instance Methods
Deletes all the values and eventually the variable itself
GoodData::MdObject#delete
# File lib/gooddata/models/metadata/variable.rb, line 91 def delete values.pmap(&:delete) super end
Retrieves variable values and returns only those related to project
@return [Array<GoodData::VariableUserFilter>] Values of variable related to project
# File lib/gooddata/models/metadata/variable.rb, line 86 def project_values values.select { |x| x.level == :project } end
Method used for replacing values in their state according to mapping. Can be used to replace any values but it is typically used to replace the URIs. Returns a new object of the same type.
@param [Array<Array>]Mapping specifying what should be exchanged for what. As mapping should be used output of GoodData::Helpers.prepare_mapping
. @return [GoodData::Variable]
# File lib/gooddata/models/metadata/variable.rb, line 79 def replace(mapping) GoodData::MdObject.replace_quoted(self, mapping) end
Retrieves variable values and returns only those related to user
@return [Array<GoodData::VariableUserFilter>] Values of variable related to user
# File lib/gooddata/models/metadata/variable.rb, line 69 def user_values values.select { |x| x.level == :user } end
Retrieves variable values
@return [Array<GoodData::VariableUserFilter>] Values of variable
# File lib/gooddata/models/metadata/variable.rb, line 54 def values payload = { variablesSearch: { variables: [ uri ], context: [] } } client.post("/gdc/md/#{project.pid}/variables/search", payload)['variables'].map { |f| client.create(GoodData::VariableUserFilter, f, project: project) } end