module Rubylog::ContextModules::Checks

Public Instance Methods

check(goal=nil, &block) click to toggle source

Tries to prove goal (or block if goal is not given). If it proves, calles check_passed. If it fails, calls check_failed. If it raises an exception, calls check_raised_exception.

# File lib/rubylog/context_modules/checks.rb, line 16
def check goal=nil, &block
  goal ||= block
  result = nil
  begin 
    result = goal.true?
  rescue
    check_raised_exception goal, $!
  else
    if result
      check_passed goal, &block
    else
      check_failed goal, &block
    end
  end
  result
end
check_failed(goal) click to toggle source
# File lib/rubylog/context_modules/checks.rb, line 6
def check_failed goal
  raise Rubylog::CheckFailed.new(goal)
end
check_passed(goal) click to toggle source
# File lib/rubylog/context_modules/checks.rb, line 3
def check_passed goal
end
check_raised_exception(goal, exception) click to toggle source
# File lib/rubylog/context_modules/checks.rb, line 10
def check_raised_exception goal, exception
  raise exception
end