Class: Tempfile
Class Method Summary collapse
- ._nuggets_original_open ⇒ Object
-
.open(*args) ⇒ Object
If no block is given, this is a synonym for new().
Class Method Details
._nuggets_original_open ⇒ Object
33 |
# File 'lib/nuggets/tempfile/open.rb', line 33 alias_method :_nuggets_original_open, :open |
.open(*args) ⇒ Object
If no block is given, this is a synonym for new().
If a block is given, it will be passed tempfile as an argument, and the tempfile will automatically be closed when the block terminates. In this case, open() returns tempfile – in contrast to the original implementation, which returns nil
.
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/nuggets/tempfile/open.rb', line 41 def open(*args) tempfile = new(*args) if block_given? begin yield tempfile ensure tempfile.close end end tempfile end |