Class: Proc
Instance Method Summary collapse
-
#change? ⇒ Boolean
TODO: Put in facets? TODO: wrong place, change yield?.
- #raises?(exception = Exception, *args) ⇒ Boolean
- #throws?(sym, *args) ⇒ Boolean
Instance Method Details
#change? ⇒ Boolean
TODO: Put in facets? TODO: wrong place, change yield?
162 163 164 165 166 167 |
# File 'lib/ae/core_ext/helpers.rb', line 162 def change? pre_result = yield called = call post_result = yield pre_result != post_result end |
#raises?(exception = Exception, *args) ⇒ Boolean
138 139 140 141 142 143 144 145 |
# File 'lib/ae/core_ext/helpers.rb', line 138 def raises?(exception=Exception, *args) begin call(*args) false rescue exception => error exception === error end end |
#throws?(sym, *args) ⇒ Boolean
148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/ae/core_ext/helpers.rb', line 148 def throws?(sym, *args) catch(sym) do begin call(*args) rescue ArgumentError # 1.9 exception rescue NameError # 1.8 exception end return false end return true end |