Class: Proc

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

Instance Method Summary collapse

Instance Method Details

#change?Boolean

Returns:

  • (Boolean)


462
463
464
465
466
467
# File 'lib/mac_bacon.rb', line 462

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

#raise?(*exceptions) ⇒ Boolean

Returns:

  • (Boolean)


446
447
448
449
450
451
452
# File 'lib/mac_bacon.rb', line 446

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

#throw?(sym) ⇒ Boolean

Returns:

  • (Boolean)


454
455
456
457
458
459
460
# File 'lib/mac_bacon.rb', line 454

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