public
Description: IronNails brings rails like development to IronRuby and WPF/Silverlight
Homepage: http://flanders.co.nz/2008/08/07/ironnails-introduction/
Clone URL: git://github.com/casualjim/ironnails.git
Click here to lend your support to: ironnails and make a donation at www.pledgie.com !
100644 28 lines (24 sloc) 0.64 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
module Kernel
 
  # Sets $VERBOSE to nil for the duration of the block and back to its original value afterwards.
  #
  # silence_warnings do
  # value = noisy_call # no warning voiced
  # end
  #
  # noisy_call # warning voiced
  def silence_warnings
    old_verbose, $VERBOSE = $VERBOSE, nil
    yield
  ensure
    $VERBOSE = old_verbose
  end
  
  def using(o)
    begin
      yield if block_given?
    ensure
      # TODO: When IronRuby is fixed so that it can call the public overload
      # of the parent class again remove the bool, some classes don't follow that convention.
      o.dispose true if o
    end
  end
  
 
end