Module: Rubylog::ContextModules::Checks
- Included in:
- Rubylog::Context
- Defined in:
- lib/rubylog/context_modules/checks.rb
Instance Method Summary collapse
-
#check(goal = nil, &block) ⇒ Object
Tries to prove goal (or block if goal is not given).
- #check_failed(goal) ⇒ Object
- #check_passed(goal) ⇒ Object
- #check_raised_exception(goal, exception) ⇒ Object
Instance Method Details
#check(goal = nil, &block) ⇒ Object
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
.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# 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) ⇒ Object
6 7 8 |
# File 'lib/rubylog/context_modules/checks.rb', line 6 def check_failed goal raise Rubylog::CheckFailed.new(goal) end |
#check_passed(goal) ⇒ Object
3 4 |
# File 'lib/rubylog/context_modules/checks.rb', line 3 def check_passed goal end |
#check_raised_exception(goal, exception) ⇒ Object
10 11 12 |
# File 'lib/rubylog/context_modules/checks.rb', line 10 def check_raised_exception goal, exception raise exception end |