Module: CMDx::Utils::Condition
Overview
Provides conditional evaluation utilities for CMDx tasks and workflows.
This module handles conditional logic evaluation with support for if and unless conditions using various callable types including symbols, procs, and objects responding to call.
Instance Method Summary collapse
-
#evaluate(target, options) ⇒ Boolean
Evaluates conditional logic based on provided options.
Instance Method Details
#evaluate(target, options) ⇒ Boolean
Evaluates conditional logic based on provided options.
Supports both if and unless conditions, with unless taking precedence when both are specified. Returns true if no conditions are provided.
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/cmdx/utils/condition.rb', line 56 def evaluate(target, , ...) case in if: if_cond, unless: unless_cond EVAL.call(target, if_cond, ...) && !EVAL.call(target, unless_cond, ...) in if: if_cond EVAL.call(target, if_cond, ...) in unless: unless_cond !EVAL.call(target, unless_cond, ...) else true end end |