Skip to content

Instantly share code, notes, and snippets.

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