module TwitterAds::Resource::InstanceMethods

Public Instance Methods

inspect() click to toggle source

Returns an inspection string for the current object instance.

@example

object.inspect

@return [String] The object instance details.

@since 0.1.0

# File lib/twitter-ads/resources/resource.rb, line 42
def inspect
  str = +"#<#{self.class.name}:0x#{object_id}"
  str << " id=\"#{@id}\"" if @id
  str << ' deleted="true"' if @deleted
  str << '>'
end
reload!(opts = {}) click to toggle source

Reloads all attributes for the current object instance from the API.

@example

object.reload!

Note: calls to this method dispose of any unsaved data on the object instance.

@param opts [Hash] An optional Hash of extended request options.

@return [self] The reloaded instance of the current object.

@since 0.1.0

# File lib/twitter-ads/resources/resource.rb, line 26
def reload!(opts = {})
  return self unless id
  params   = { with_deleted: true }.merge!(opts)
  resource = self.class::RESOURCE % { account_id: account.id, id: id }
  response = Request.new(account.client, :get, resource, params: params).perform
  from_response(response.body[:data])
end