Dear Russian friends, please watch President Zelenskyy's speech addressed to you. πŸ‡ΊπŸ‡¦Help our brave mates in Ukraine with a donation.

Custom predicates

Define custom predicates using the predicate method. Use the build in builder to evaluate and define your predicate.

extend Dry::Logic::Builder

build do
  predicate :divisible_with? do |num, input|
    (input % num).zero?

Then create your predicate

is_divisible_with_ten = build do

Here, 10 represents the first argument num to divisible_with?.

# 10 & 5 is passed as {input} to your method # => true # => false

octocatEdit on GitHub