Created
November 10, 2011 18:16
-
-
Save imajes/1355625 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class Foo | |
has_one :image | |
def process_stuff | |
img = Image.first | |
img.with_temp_file('/path/to/tmpfile') do |tf| | |
tf.rotate | |
tf.bounce | |
tf.other_thing | |
img.save(:file => tf) | |
end | |
end | |
end | |
class Image | |
belongs_to :foo | |
def with_temp_file(path, &block) | |
# download content, put it into a local fle | |
tf = open(path, 'wb') { |fh| | |
fh.write(downloaded_content) | |
yield | |
} | |
tf.delete | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment