Class: Proc

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

Instance Method Summary collapse

Instance Method Details

#change?Boolean

Returns:

  • (Boolean)


265
266
267
268
269
270
# File 'lib/bacon.rb', line 265

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

#raise?(*exceptions) ⇒ Boolean

Returns:

  • (Boolean)


249
250
251
252
253
254
255
# File 'lib/bacon.rb', line 249

def raise?(*exceptions)
  call
rescue *(exceptions.empty? ? RuntimeError : exceptions) => e
  e
else
  false
end

#throw?(sym) ⇒ Boolean

Returns:

  • (Boolean)


257
258
259
260
261
262
263
# File 'lib/bacon.rb', line 257

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