Module: Contentful::Management::Resource::Refresher
- Included in:
- Asset, ContentType, Entry, Locale, Space
- Defined in:
- lib/contentful/management/resource/refresher.rb
Overview
Adds the feature to have properties and system data reload for Resource.
Instance Method Summary collapse
- #refresh_data(resource) ⇒ Object
-
#reload ⇒ Object
Reload an object Updates the current version of the object to the version on the system.
Instance Method Details
#refresh_data(resource) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/contentful/management/resource/refresher.rb', line 15 def refresh_data(resource) if resource.is_a? Error resource else @properties = resource.instance_variable_get(:@properties) @fields = resource.instance_variable_get(:@fields) if self.is_a?(Contentful::Management::Entry) @sys = resource.instance_variable_get(:@sys).merge(locale: locale) self end end |
#reload ⇒ Object
Reload an object Updates the current version of the object to the version on the system
10 11 12 13 |
# File 'lib/contentful/management/resource/refresher.rb', line 10 def reload 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 |