Created
May 2, 2013 20:56
-
-
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?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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