class Dry::Logic::Builder::Context
def call(&)
- See: Builder#call -
def call(&) instance_eval(&) end
def initialize
def initialize Operations.constants(false).each do |name| next if IGNORED_OPERATIONS.include?(name) operation = Operations.const_get(name) define_singleton_method(name.downcase) do |*args, **kwargs, &block| operation.new(*call(&block), *args, **kwargs) end end Predicates::Methods.instance_methods(false).each do |name| unless IGNORED_PREDICATES.include?(name) predicate(name, Predicates[name]) end end end
def predicate(name, context = nil, &block)
@name [Symbol] Name of predicate
Defines custom predicate
def predicate(name, context = nil, &block) if singleton_class.method_defined?(name) singleton_class.undef_method(name) end predicate = Rule::Predicate.new(context || block) define_singleton_method(name) do |*args| predicate.curry(*args) end end