Class: Proc

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

Instance Method Summary collapse

Instance Method Details

#change?Boolean

Returns:

  • (Boolean)


358
359
360
361
362
363
# File 'lib/mac_bacon.rb', line 358

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

#raise?(*exceptions) ⇒ Boolean

Returns:

  • (Boolean)


342
343
344
345
346
347
348
# File 'lib/mac_bacon.rb', line 342

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

#throw?(sym) ⇒ Boolean

Returns:

  • (Boolean)


350
351
352
353
354
355
356
# File 'lib/mac_bacon.rb', line 350

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