Sha256: b453f99867e49c52dd4f35ab22cce62227f1dddd9e2bbd8ce11bc197ef93a735

Contents?: true

Size: 911 Bytes

Versions: 12

Compression:

Stored size: 911 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, 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

12 entries across 12 versions & 1 rubygems

Version Path
contentful-management-1.10.1 lib/contentful/management/resource/refresher.rb
contentful-management-1.10.0 lib/contentful/management/resource/refresher.rb
contentful-management-1.9.0 lib/contentful/management/resource/refresher.rb
contentful-management-1.8.1 lib/contentful/management/resource/refresher.rb
contentful-management-1.8.0 lib/contentful/management/resource/refresher.rb
contentful-management-1.7.0 lib/contentful/management/resource/refresher.rb
contentful-management-1.6.0 lib/contentful/management/resource/refresher.rb
contentful-management-1.5.0 lib/contentful/management/resource/refresher.rb
contentful-management-1.4.0 lib/contentful/management/resource/refresher.rb
contentful-management-1.3.0 lib/contentful/management/resource/refresher.rb
contentful-management-1.2.0 lib/contentful/management/resource/refresher.rb
contentful-management-1.1.0 lib/contentful/management/resource/refresher.rb