Sha256: 9abafb173a0ecc50a1483b064fe11d874741c8f53d27e51b0f03e2c026a93f63

Contents?: true

Size: 378 Bytes

Versions: 7

Compression:

Stored size: 378 Bytes

Contents

class Symbol

  # Does the block throw the symbol?
  # 
  def thrown?
    catch(self) do
      begin
        yield
        true
      rescue ArgumentError => err     # 1.9 exception
        false  #msg += ", not #{err.message.split(/ /).last}"
      rescue NameError => err         # 1.8 exception
        false  #msg += ", not #{err.name.inspect}"
      end
    end
  end

end

Version data entries

7 entries across 6 versions & 1 rubygems

Version Path
facets-2.9.3 lib/core/facets/symbol/thrown.rb
facets-2.9.2 lib/core/facets/symbol/thrown.rb
facets-2.9.2 src/core/facets/symbol/thrown.rb
facets-2.9.1 lib/core/facets/symbol/thrown.rb
facets-2.9.0 lib/core/facets/symbol/thrown.rb
facets-2.9.0.pre.2 lib/core/facets/symbol/thrown.rb
facets-2.9.0.pre.1 lib/core/facets/symbol/thrown.rb