Skip to content
This repository was archived by the owner on Apr 17, 2018. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/dm-adjust/collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@ def adjust(attributes = {}, reload = false)
#
# @api public
def adjust!(attributes = {}, reload = false)
return true if attributes.empty?
return 0 if attributes.empty?

reload_conditions = if reload
model_key = model.key(repository.name)
Query.target_conditions(self, model_key, model_key)
end

adjust_attributes = adjust_attributes(attributes)
repository.adjust(adjust_attributes, self)
affected_resource_count = repository.adjust(adjust_attributes, self)

if reload_conditions
@query.clear
@query.update(:conditions => reload_conditions)
self.reload
end

true
affected_resource_count
end

private
Expand Down