Skip to content

Instantly share code, notes, and snippets.

/ruby.rb Secret

Created August 13, 2015 16:30
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 anonymous/2ab33c376db46ee19101 to your computer and use it in GitHub Desktop.
Save anonymous/2ab33c376db46ee19101 to your computer and use it in GitHub Desktop.
def validate()
balance = @mysql.query("SELECT Balance FROM Balance WHERE AccountID = #{@sender_id} ORDER BY Date DESC LIMIT 1")
if balance >= @amount
return true
else
return false
end
end
# Esegue il bonifico con una query MySQL
def do()
if self.validate
@mysql.query("CALL Transfer(#{@sender_id}, #{@recipient_id}, #{@amount})")
end
end
@havenwood
Copy link

Rather than the whole if statement with return true and return false just:

balance >= @amount

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment