Module: Preconditions::PreconditionModuleClassMethods
- Included in:
- Preconditions
- Defined in:
- lib/preconditions.rb
Instance Method Summary collapse
-
#check(argument, name = nil, &block) ⇒ Object
Introduce a DSL expression to check the given argument, with the optionally given name.
Instance Method Details
#check(argument, name = nil, &block) ⇒ Object
Introduce a DSL expression to check the given argument, with the optionally given name. This will return a
- ConditionChecker
-
instance that can be used to build the DSL expression.
96 97 98 99 100 101 102 103 104 |
# File 'lib/preconditions.rb', line 96 def check(argument, name = nil, &block) cc = ConditionChecker.new(argument, name) if block_given? cc.instance_eval(&block) argument # return the argument if a block is given to evaluate the check immediately else cc # return the checker if no evaluation block is supplied end end |