Method: GoodData::MdObject#save_as

Defined in:
lib/gooddata/models/metadata.rb

#save_as(new_title = nil) ⇒ GoodData::MdObject

Saves an object with a different name

Parameters:

  • new_title (String) (defaults to: nil)

    New title. If not provided one is provided

Returns:



265
266
267
268
269
270
271
272
273
274
275
# File 'lib/gooddata/models/metadata.rb', line 265

def save_as(new_title = nil)
  new_title = "Clone of #{title}" if new_title.nil?
  # rubocop:disable Security/MarshalLoad
  dupped = Marshal.load(Marshal.dump(json))
  # rubocop:enable Security/MarshalLoad
  dupped[root_key]['meta'].delete('uri')
  dupped[root_key]['meta'].delete('identifier')
  dupped[root_key]['meta']['title'] = new_title
  x = client.create(self.class, dupped, :project => project)
  x.save
end