Sha256: 1b0094f30af0ba1f3e675a39aba37e5d89e772a033f51c8e91edae40931408cd

Contents?: true

Size: 880 Bytes

Versions: 12

Compression:

Stored size: 880 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
          self_class = self.class
          resource = self.is_a?(Space) ? self_class.find(id) : self_class.find(space.id, id)
          refresh_data(resource) if resource.is_a? self_class
        end

        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-0.8.0 lib/contentful/management/resource/refresher.rb
contentful-management-0.7.3 lib/contentful/management/resource/refresher.rb
contentful-management-0.7.2 lib/contentful/management/resource/refresher.rb
contentful-management-0.7.1 lib/contentful/management/resource/refresher.rb
contentful-management-0.7.0 lib/contentful/management/resource/refresher.rb
contentful-management-0.6.1 lib/contentful/management/resource/refresher.rb
contentful-management-0.6.0 lib/contentful/management/resource/refresher.rb
contentful-management-0.5.0 lib/contentful/management/resource/refresher.rb
contentful-management-0.4.1 lib/contentful/management/resource/refresher.rb
contentful-management-0.4.0 lib/contentful/management/resource/refresher.rb
contentful-management-0.3.1 lib/contentful/management/resource/refresher.rb
contentful-management-0.3.0 lib/contentful/management/resource/refresher.rb