Skip to content

Instantly share code, notes, and snippets.

@tansengming
Created February 21, 2017 16:16
Show Gist options
  • Save tansengming/09be8c07c57e29946d2cb0a229b29886 to your computer and use it in GitHub Desktop.
Save tansengming/09be8c07c57e29946d2cb0a229b29886 to your computer and use it in GitHub Desktop.
# Job 1
sms_credits = community.sms_credits # start with 100 credits
if sms_credits > 0
send_sms recipient, message
# take off a credit
community.sms_credits = sms_credits - 1
community.save # 99 credits
end
# Switch! -------------------------------------------------------------------
# Job 2
sms_credits = community.sms_credits # 99 credits
if sms_credits > 0
send_sms recipient, message
# take off a credit
community.sms_credits = sms_credits - 1
community.save # 98 credits
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment