Class: Proc

Inherits:
Object show all
Defined in:
lib/scampi/monkey_patches.rb

Instance Method Summary collapse

Instance Method Details

#change?Boolean

Returns:

  • (Boolean)


31
32
33
34
35
36
# File 'lib/scampi/monkey_patches.rb', line 31

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

#raise?(*exceptions) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
18
19
20
21
# File 'lib/scampi/monkey_patches.rb', line 15

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

#throw?(sym) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
26
27
28
29
# File 'lib/scampi/monkey_patches.rb', line 23

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