Sha256: fee8d31116e6b86689d01ce370e88fadc5b0d1a3018842bee3048ebe1e37478c

Contents?: true

Size: 927 Bytes

Versions: 14

Compression:

Stored size: 927 Bytes

Contents

module Contentful
  module Management
    module Resource
      # Adds the feature to have properties and system data reload for Resource.
      module Refresher
        # Reload an object
        # Updates the current version of the object to the version on the system
        def reload
          resource = refresh_find
          refresh_data(resource) if resource.is_a? self.class
        end

        # @private
        def refresh_find
          self.class.find(client, space.id, environment_id, id)
        end

        # @private
        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)
            self
          end
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
contentful-management-2.8.0 lib/contentful/management/resource/refresher.rb
contentful-management-2.7.0 lib/contentful/management/resource/refresher.rb
contentful-management-2.6.0 lib/contentful/management/resource/refresher.rb
contentful-management-2.5.0 lib/contentful/management/resource/refresher.rb
contentful-management-2.4.0 lib/contentful/management/resource/refresher.rb
contentful-management-2.3.0 lib/contentful/management/resource/refresher.rb
contentful-management-2.2.2 lib/contentful/management/resource/refresher.rb
contentful-management-2.2.1 lib/contentful/management/resource/refresher.rb
contentful-management-2.2.0 lib/contentful/management/resource/refresher.rb
contentful-management-2.1.1 lib/contentful/management/resource/refresher.rb
contentful-management-2.1.0 lib/contentful/management/resource/refresher.rb
contentful-management-2.0.2 lib/contentful/management/resource/refresher.rb
contentful-management-2.0.1 lib/contentful/management/resource/refresher.rb
contentful-management-2.0.0 lib/contentful/management/resource/refresher.rb