Class: GoodData::Variable
- Inherits:
-
MdObject
- Object
- Rest::Object
- Rest::Resource
- MdObject
- GoodData::Variable
- Defined in:
- lib/gooddata/models/metadata/variable.rb
Constant Summary
Constants inherited from MdObject
MdObject::IDENTIFIERS_CFG, MdObject::MD_OBJ_CTG
Constants included from Mixin::MdIdToUri
Mixin::MdIdToUri::IDENTIFIERS_CFG
Constants included from Mixin::MdObjectIndexer
Mixin::MdObjectIndexer::MD_OBJ_CTG
Constants included from Mixin::MdObjectQuery
Mixin::MdObjectQuery::ERROR_MESSAGE_NO_PROJECT
Instance Attribute Summary
Attributes inherited from Rest::Object
Class Method Summary collapse
-
.all(options = { :client => GoodData.connection, :project => GoodData.project }) ⇒ Array<GoodData::MdObject> | Array<Hash>
Method intended to get all objects of that type in a specified project.
- .create(data, options = { :client => GoodData.connection, :project => GoodData.project }) ⇒ Object
Instance Method Summary collapse
-
#delete ⇒ Object
Deletes all the values and eventually the variable itself.
-
#project_values ⇒ Array<GoodData::VariableUserFilter>
Retrieves variable values and returns only those related to project.
-
#replace(mapping) ⇒ GoodData::Variable
Method used for replacing values in their state according to mapping.
-
#user_values ⇒ Array<GoodData::VariableUserFilter>
Retrieves variable values and returns only those related to user.
-
#values ⇒ Array<GoodData::VariableUserFilter>
Retrieves variable values.
Methods inherited from MdObject
#==, #add_tag, #browser_uri, #deprecated, #deprecated=, find_replaceable_values, #get_flag?, #initialize, #listed?, #production, #production=, #project, #reload!, #remove_tag, replace, #replace!, replace_bracketed, replace_quoted, #restricted, #restricted=, #save, #save_as, #set_flag, #tag_set, #unlisted, #unlisted=, #validate
Methods included from Mixin::MdIdToUri
Methods included from Mixin::MdObjectIndexer
Methods included from Mixin::MdObjectQuery
#all, #dependency, #dependency?, #query, #usedby, #usedby?, #using, #using?
Methods included from Mixin::MdFinders
#find_by_identifier, #find_by_tag, #find_by_title, #find_first_by_identifier, #find_first_by_title
Methods included from Mixin::MdObjId
Methods included from Mixin::MdGrantees
#change_permission, #grant, #grantees, #revoke
Methods included from Mixin::MdRelations
#dependency, #dependency?, #usedby, #usedby?, #using, #using?
Methods included from Mixin::ObjId
Methods included from Mixin::Links
Methods inherited from Rest::Resource
Methods inherited from Rest::Object
client, default_client, #initialize, #saved?
Methods included from Mixin::DataPropertyReader
Methods included from Mixin::DataPropertyWriter
Methods included from Mixin::MetaPropertyReader
Methods included from Mixin::MetaPropertyWriter
Methods included from Mixin::MetaGetter
Methods included from Mixin::DataGetter
Methods included from Mixin::RootKeyGetter
Methods included from Mixin::ContentGetter
Constructor Details
This class inherits a constructor from GoodData::MdObject
Class Method Details
.all(options = { :client => GoodData.connection, :project => GoodData.project }) ⇒ Array<GoodData::MdObject> | Array<Hash>
Method intended to get all objects of that type in a specified project
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
22 23 24 |
# File 'lib/gooddata/models/metadata/variable.rb', line 22 def all( = { :client => GoodData.connection, :project => GoodData.project }) query('prompt', Variable, ) end |
.create(data, options = { :client => GoodData.connection, :project => GoodData.project }) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/gooddata/models/metadata/variable.rb', line 26 def create(data, = { :client => GoodData.connection, :project => GoodData.project }) title = data[:title] project = [:project] c = client() 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 |
Instance Method Details
#delete ⇒ Object
Deletes all the values and eventually the variable itself
91 92 93 94 |
# File 'lib/gooddata/models/metadata/variable.rb', line 91 def delete values.pmap(&:delete) super end |
#project_values ⇒ Array<GoodData::VariableUserFilter>
Retrieves variable values and returns only those related to project
86 87 88 |
# File 'lib/gooddata/models/metadata/variable.rb', line 86 def project_values values.select { |x| x.level == :project } end |
#replace(mapping) ⇒ GoodData::Variable
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.
79 80 81 |
# File 'lib/gooddata/models/metadata/variable.rb', line 79 def replace(mapping) GoodData::MdObject.replace_quoted(self, mapping) end |
#user_values ⇒ Array<GoodData::VariableUserFilter>
Retrieves variable values and returns only those related to user
69 70 71 |
# File 'lib/gooddata/models/metadata/variable.rb', line 69 def user_values values.select { |x| x.level == :user } end |
#values ⇒ Array<GoodData::VariableUserFilter>
Retrieves variable values
54 55 56 57 58 59 60 61 62 63 64 |
# 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 |