Skip to content

Instantly share code, notes, and snippets.

Created August 15, 2015 10:24
Show Gist options
  • Save anonymous/21f6020e6085e517f159 to your computer and use it in GitHub Desktop.
Save anonymous/21f6020e6085e517f159 to your computer and use it in GitHub Desktop.
# Function transfer in Account class
def transfer(recipient_id, amount)
result = @db.query("SELECT Balance FROM Balance WHERE AccountID = #{@account_id} ORDER BY Date DESC LIMIT 1")
if result.first['Balance'] >= amount
puts @db.query("CALL Transfer(#{@account_id}, #{recipient_id}, #{amount})").inspect
puts nil.inspect
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment