Created
February 10, 2016 15:55
-
-
Save rmg/32b886b2874a67d7db5f to your computer and use it in GitHub Desktop.
mktmpio examples
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
# Inspiring DSL for temp directories | |
Dir.mktmpdir {|dir| | |
# use the directory... | |
open("#{dir}/foo", "w") { ... } | |
} | |
# Provide the same ergonomics for databases | |
mktmpio(:postgres) {|db| | |
pg.connect(db) {|conn| | |
# use the database... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment