lib/bcdd/result/context/mixin.rb in bcdd-result-0.10.0 vs lib/bcdd/result/context/mixin.rb in bcdd-result-0.11.0

- old
+ new

@@ -11,26 +11,34 @@ def Failure(type, **value) _ResultAs(Failure, type, value) end - private def _ResultAs(kind_class, type, value, halted: nil) - kind_class.new(type: type, value: value, subject: self, halted: halted) + private def _ResultAs(kind_class, type, value, terminal: nil) + kind_class.new(type: type, value: value, subject: self, terminal: terminal) end end module Addons - module Continuable + module Continue def Success(type, **value) - _ResultAs(Success, type, value, halted: true) + _ResultAs(Success, type, value, terminal: true) end private def Continue(**value) _ResultAs(Success, :continued, value) end end - OPTIONS = { continue: Continuable }.freeze + module Given + private def Given(*values) + value = values.map(&:to_h).reduce({}) { |acc, val| acc.merge(val) } + + _ResultAs(Success, :given, value) + end + end + + OPTIONS = { continue: Continue, given: Given }.freeze def self.options(config_flags) ::BCDD::Result::Config::Options.addon(map: config_flags, from: OPTIONS) end end