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?
173 174 175 176 177 178 |
# File 'lib/ae/core_ext.rb', line 173 def change? pre_result = yield called = call post_result = yield pre_result != post_result end |
#raises?(exception = Exception, *args) ⇒ Boolean
149 150 151 152 153 154 155 156 |
# File 'lib/ae/core_ext.rb', line 149 def raises?(exception=Exception, *args) begin call(*args) false rescue exception => error exception === error end end |
#throws?(sym, *args) ⇒ Boolean
159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/ae/core_ext.rb', line 159 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 |