lib/gooddata/models/metadata/report.rb in gooddata-0.6.24 vs lib/gooddata/models/metadata/report.rb in gooddata-0.6.25
- old
+ new
@@ -7,14 +7,12 @@
require_relative '../metadata'
require_relative 'metadata'
module GoodData
class Report < GoodData::MdObject
- root_key :report
+ include Mixin::Lockable
- include GoodData::Mixin::Lockable
-
class << self
# 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
@@ -22,19 +20,12 @@
def all(options = { :client => GoodData.connection, :project => GoodData.project })
query('report', Report, options)
end
def create(options = { :client => GoodData.connection, :project => GoodData.project })
- client = options[:client]
- fail ArgumentError, 'No :client specified' if client.nil?
+ client, project = GoodData.get_client_and_project(options)
- p = options[:project]
- fail ArgumentError, 'No :project specified' if p.nil?
-
- project = client.projects(p)
- fail ArgumentError, 'Wrong :project specified' if project.nil?
-
title = options[:title]
fail 'Report needs a title specified' unless title
summary = options[:summary] || ''
rd = options[:rd] || ReportDefinition.create(options)
rd.save
@@ -206,18 +197,16 @@
remove_definition(uri)
end
self
end
- # Replaces all occurences of something with something else. This is just a convenience method. The
- # real work is done under the hood in report definition. This is just deferring to those
+ # 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 what [Object] What you would like to have changed
- # @param for_what [Object] What you would like to have changed this for
- # @return [GoodData::Report] Returns report with removed definition
- def replace(what, for_what)
+ # @param [Array<Array>]Mapping specifying what should be exchanged for what. As mapping should be used output of GoodData::Helpers.prepare_mapping.
+ # @return [GoodData::Report]
+ def replace(mapping)
new_defs = definitions.map do |rep_def|
- rep_def.replace(what, for_what)
+ rep_def.replace(mapping)
end
new_defs.pmap(&:save)
self
end