lib/gooddata/models/project_metadata.rb in gooddata-0.6.24 vs lib/gooddata/models/project_metadata.rb in gooddata-0.6.25
- old
+ new
@@ -10,16 +10,12 @@
def keys(opts = { :client => GoodData.connection, :project => GoodData.project })
ProjectMetadata[:all, opts].keys
end
def [](key, opts = { :client => GoodData.connection, :project => GoodData.project })
- client = opts[:client]
- fail ArgumentError, 'No :client specified' if client.nil?
+ client, project = GoodData.get_client_and_project(opts)
- project = opts[:project]
- fail ArgumentError, 'No :project specified' if project.nil?
-
if key == :all
uri = "/gdc/projects/#{project.pid}/dataload/metadata"
res = client.get(uri)
res['metadataItems']['items'].reduce({}) do |memo, i|
memo[i['metadataItem']['key']] = i['metadataItem']['value']
@@ -41,14 +37,10 @@
rescue RestClient::ResourceNotFound
false
end
def []=(key, opts = { :client => GoodData.connection, :project => GoodData.project }, val = nil)
- client = opts[:client]
- fail ArgumentError, 'No :client specified' if client.nil?
-
- project = opts[:project]
- fail ArgumentError, 'No :project specified' if project.nil?
+ client, project = GoodData.get_client_and_project(opts)
data = {
:metadataItem => {
:key => key,
:value => val