Sha256: 19994cd70d257e70628e11ecbcda83ca63ba6ad3669dde882aa4d25fd8c68cac

Contents?: true

Size: 772 Bytes

Versions: 4

Compression:

Stored size: 772 Bytes

Contents

# encoding: utf-8
require 'simplecov'

$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
require "io_shuten"

### MONKEY PATCH raise

# usage: raise my_instance
#        raise :foo
#        raise anything_else_which_is_an_object
#        raise foo.bar.baz

class Module
  def alias_method_chain( target, feature )
    alias_method "#{target}_without_#{feature}", target
    alias_method target, "#{target}_with_#{feature}"
  end
end

class Object
  def raise_with_helpfulness(*args)
    raise_without_helpfulness(*args)
  rescue TypeError => e
    raise_without_helpfulness args.first.inspect if ['exception class/object expected', 'exception object expected'].include?(e.to_s)
    raise_without_helpfulness e
  end
  alias_method_chain :raise, :helpfulness
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
io_shuten-0.0.1.dev4 spec/spec_helper.rb
io_shuten-0.0.1.dev3 spec/spec_helper.rb
io_shuten-0.0.1.dev1 spec/spec_helper.rb
io_shuten-0.0.1.dev0 spec/spec_helper.rb