Skip to content

Instantly share code, notes, and snippets.

@bhardin
Last active August 29, 2015 14:00
Show Gist options
  • Save bhardin/3439ec251f1a7ac04cc6 to your computer and use it in GitHub Desktop.
Save bhardin/3439ec251f1a7ac04cc6 to your computer and use it in GitHub Desktop.
Which way is better?

Option 1

if target.last_sent_at && target.last_sent_at >= Time.now - 23.hours && !ignore_rules
  next
end

Option 2

if target.last_sent_at && target.last_sent_at >= Time.now - 23.hours
  next unless ignore_rules
end

Option 3

...
next unless should_deliver? || ignore_rules
...

def should_deliver?
  target.last_sent_at && target.last_sent_at >= Time.now - 23.hours
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment