motion-prime/models/sync.rb in motion-prime-0.2.0 vs motion-prime/models/sync.rb in motion-prime-0.2.1

- old
+ new

@@ -6,11 +6,11 @@ base.class_attribute :_associations end def sync_url(method = :get) url = self.class.sync_url - url = url.call(method) if url.is_a?(Proc) + url = url.call(method, self) if url.is_a?(Proc) normalize_sync_url(url) end # destroy on server and delete on local def destroy(&block) @@ -49,11 +49,11 @@ should_fetch = false should_update = false end should_fetch = !new_record? if should_fetch.nil? - should_update = new_record? if should_update.nil? + should_update ||= new_record? unless should_fetch fetch_with_url url do save if sync_options[:save] block.call if use_callback end if should_fetch @@ -184,11 +184,10 @@ def filtered_updatable_attributes(options = {}) slice_attributes = options[:updatable_attributes].map(&:to_sym) if options.has_key?(:updatable_attributes) updatable_attributes = self.class.updatable_attributes if updatable_attributes.blank? - attrs = attributes_hash.slice(*slice_attributes) if slice_attributes - return attrs + return slice_attributes ? attributes_hash.slice(*slice_attributes) : attributes_hash end updatable_attributes = updatable_attributes.slice(*slice_attributes) if slice_attributes updatable_attributes.to_a.inject({}) do |hash, attribute| key, options = *attribute \ No newline at end of file