module Contentful::Management::Resource::Refresher

Adds the feature to have properties and system data reload for Resource.

Public Instance Methods

refresh_data(resource) click to toggle source

@private

# File lib/contentful/management/resource/refresher.rb, line 23
def refresh_data(resource)
  if resource.is_a? Error
    resource
  else
    @properties = resource.instance_variable_get(:@properties)
    @fields = resource.instance_variable_get(:@fields)
    @sys = resource.instance_variable_get(:@sys).merge(locale: locale)
    @_metadata = resource.instance_variable_get(:@_metadata)
    self
  end
end
refresh_find() click to toggle source

@private

# File lib/contentful/management/resource/refresher.rb, line 16
def refresh_find
  return self.class.find(client, space.id, environment_id, id) if environment_id

  self.class.find(client, space.id, id)
end
reload() click to toggle source

Reload an object Updates the current version of the object to the version on the system

# File lib/contentful/management/resource/refresher.rb, line 10
def reload
  resource = refresh_find
  refresh_data(resource) if resource.is_a? self.class
end