Class: Proc
- Includes:
- Assay::Bang::ProcMethods
- Defined in:
- lib/assay/bang.rb,
lib/assay/ae/core_ext.rb
Instance Method Summary collapse
-
#change? ⇒ Boolean
Does calling the procedure change what the block returns?.
-
#raises?(exception = Exception, *args) ⇒ Boolean
Does calling the procedure raise the exception, or a kind of it?.
-
#throws?(sym, *args) ⇒ Boolean
Does calling the procedure throw
sym? Throwing another symbol counts as no; any error is raised as usual.
Methods included from Assay::Bang::ProcMethods
#not_raises!, #not_rescues!, #not_throws!, #raises!, #rescues!, #throws!
Instance Method Details
#change? ⇒ Boolean
Does calling the procedure change what the block returns?
105 106 107 108 109 110 |
# File 'lib/assay/ae/core_ext.rb', line 105 def change? pre_result = yield call post_result = yield pre_result != post_result end |
#raises?(exception = Exception, *args) ⇒ Boolean
Does calling the procedure raise the exception, or a kind of it?
84 85 86 87 88 89 |
# File 'lib/assay/ae/core_ext.rb', line 84 def raises?(exception=Exception, *args) call(*args) false rescue exception => error exception === error end |
#throws?(sym, *args) ⇒ Boolean
Does calling the procedure throw sym? Throwing another symbol
counts as no; any error is raised as usual.
93 94 95 96 97 98 99 100 101 102 |
# File 'lib/assay/ae/core_ext.rb', line 93 def throws?(sym, *args) catch(sym) do begin call(*args) rescue UncaughtThrowError end return false end return true end |