Skip to content

Instantly share code, notes, and snippets.

@dhonig
Created September 18, 2015 00:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhonig/97dff96ea26791fb20ce to your computer and use it in GitHub Desktop.
Save dhonig/97dff96ea26791fb20ce to your computer and use it in GitHub Desktop.
def update!(target = nil)
return amount if closed?
if source.present?
amount = source.compute_amount(target || adjustable)
self.update_columns(
amount: amount,
updated_at: Time.now,
)
if promotion?
self.update_column(:eligible, source.promotion.eligible?(adjustable))
end
end
amount
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment