Sha256: 4563f1fc9b1d3e2455b534bc7f2a36b4b4a6a2db400e7f0d29afa405eca19b9f
Contents?: true
Size: 920 Bytes
Versions: 2
Compression:
Stored size: 920 Bytes
Contents
# frozen_string_literal: true require 'singleton' require_relative 'duck_fiber' require_relative 'nullary_relation' module MiniKraken module Core # A nullary relation that always returns success outcomes. class Succeed < NullaryRelation include Singleton # Constructor. Initialize the relation's name & freeze it... def initialize super('succeed') end # Returns a Fiber-like object (a DuckFiber). # When that object receives the message resume, it will # return a success context. # @param _actuals [Array] MUST be empty array for nullary relation. # @param _ctx [Core::Context] Runtime context # @return [Core::DuckFiber] def solver_for(_actuals, ctx) # Important: every `solver_for` call will result in a distinct Context. DuckFiber.new(-> { ctx.succeeded! }) end end # class end # module end # module
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mini_kraken-0.3.01 | lib/mini_kraken/core/succeed.rb |
mini_kraken-0.3.00 | lib/mini_kraken/core/succeed.rb |