Class: Assay::AE::Check::Proc
Overview
The Check::Proc class encapsulates a labeled procedure
for making assertions using the ok/no methods.
Instance Method Summary collapse
-
#call(*args) ⇒ Object
Call check procedure.
-
#check!(args, negated, backtrace) ⇒ Object
Assert the check for the given arguments, negated or not.
-
#initialize(options = {}, &check) ⇒ Proc
constructor
Setup new check procedure.
- #message(&block) ⇒ Object
- #message=(msg) ⇒ Object
- #no!(*args) ⇒ Object
- #ok!(*args) ⇒ Object
- #to_s(*args) ⇒ Object
Constructor Details
#initialize(options = {}, &check) ⇒ Proc
Setup new check procedure.
16 17 18 19 20 |
# File 'lib/assay/ae/check.rb', line 16 def initialize(={}, &check) @name = [:name] @message = [:message] || @name @check = check end |
Instance Method Details
#call(*args) ⇒ Object
Call check procedure.
36 37 38 |
# File 'lib/assay/ae/check.rb', line 36 def call(*args) @check.call(*args) end |
#check!(args, negated, backtrace) ⇒ Object
Assert the check for the given arguments, negated or not. The backtrace says where the failure is reported.
65 66 67 |
# File 'lib/assay/ae/check.rb', line 65 def check!(args, negated, backtrace) Assertor.assert(call(*args), ::Kernel.proc { to_s(*args) }, negated, backtrace) end |
#message(&block) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/assay/ae/check.rb', line 23 def (&block) if block @message = block end @message end |
#message=(msg) ⇒ Object
31 32 33 |
# File 'lib/assay/ae/check.rb', line 31 def (msg) @message = msg end |
#no!(*args) ⇒ Object
59 60 61 |
# File 'lib/assay/ae/check.rb', line 59 def no!(*args) check!(args, true, caller) end |
#ok!(*args) ⇒ Object
54 55 56 |
# File 'lib/assay/ae/check.rb', line 54 def ok!(*args) check!(args, false, caller) end |