Skip to content

Instantly share code, notes, and snippets.

@jtimberman
Created May 2, 2013 20:56
Show Gist options
  • Save jtimberman/5505415 to your computer and use it in GitHub Desktop.
Save jtimberman/5505415 to your computer and use it in GitHub Desktop.
When should I use a platform predicate method (#platform?, #platform_family?) vs a case statement?
# If you have a simple conditional, use a predicate:
if platform?("ubuntu")
# do things only applicable on Ubuntu
else
# do things on everything else
end
# If you have a complicated conditional for multiple platforms, use a case statement:
case node['platform']
when "debian"
# ...
when "smartos"
# ...
when "freebsd"
# ...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment