Module: Que::Utils::Assertions

Included in:
Que
Defined in:
lib/que/utils/assertions.rb

Defined Under Namespace

Classes: AssertionFailed

Instance Method Summary collapse

Instance Method Details

#assert(*args) ⇒ Object

Raises:



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/que/utils/assertions.rb', line 12

def assert(*args)
  comparison, object, pass = _check_assertion_args(*args)
  return object if pass

  message =
    if block_given?
      yield.to_s
    elsif comparison
      "Expected #{comparison.inspect}, got #{object.inspect}!"
    else
      "Assertion failed!"
    end

  # Remove this method from the backtrace, to make errors clearer.
  raise AssertionFailed, message, caller
end

#assert?(*args) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
32
# File 'lib/que/utils/assertions.rb', line 29

def assert?(*args)
  _, _, pass = _check_assertion_args(*args)
  !!pass
end