Class: Proc

Inherits:
Object show all
Defined in:
lib/vendor/bacon.rb

Instance Method Summary collapse

Instance Method Details

#change?Boolean

Returns:

  • (Boolean)


229
230
231
232
233
234
# File 'lib/vendor/bacon.rb', line 229

def change?
  pre_result = yield
  called = call
  post_result = yield
  pre_result != post_result
end

#raise?(*exceptions) ⇒ Boolean

Returns:

  • (Boolean)


205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/vendor/bacon.rb', line 205

def raise?(*exceptions)
  exceptions = [RuntimeError]  if exceptions.empty?
  call

# Only to work in 1.9.0, rescue with splat doesn't work there right now
rescue Object => e
  case e
  when *exceptions
    e
  else
    raise e
  end
else
  false
end

#throw?(sym) ⇒ Boolean

Returns:

  • (Boolean)


221
222
223
224
225
226
227
# File 'lib/vendor/bacon.rb', line 221

def throw?(sym)
  catch(sym) {
    call
    return false
  }
  return true
end