Skip to content

Instantly share code, notes, and snippets.

@Sailias
Created July 10, 2012 15:45
Show Gist options
  • Save Sailias/3084222 to your computer and use it in GitHub Desktop.
Save Sailias/3084222 to your computer and use it in GitHub Desktop.
def upgrade(attribute, amount)
val = self.class.select("UPGRADE(#{self.id}, '#{attribute}', #{amount})").where(:id => self.id).first.attributes
if val["upgrade"] == 't'
self.send("#{attribute.downcase}=", self.send("#{attribute.downcase}") + amount)
return true
end
return false
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment