lib/bcdd/result/context/mixin.rb in bcdd-result-0.7.0 vs lib/bcdd/result/context/mixin.rb in bcdd-result-0.8.0
- old
+ new
@@ -1,9 +1,11 @@
# frozen_string_literal: true
class BCDD::Result::Context
module Mixin
+ Factory = BCDD::Result::Mixin::Factory
+
module Methods
def Success(type, **value)
Success.new(type: type, value: value, subject: self)
end
@@ -17,22 +19,23 @@
private def Continue(**value)
Success.new(type: :continued, value: value, subject: self)
end
end
- OPTIONS = { Continue: Continuable }.freeze
+ OPTIONS = { continue: Continuable }.freeze
- def self.options(names)
- Array(names).filter_map { |name| OPTIONS[name] }
+ def self.options(config_flags)
+ ::BCDD::Result::Config::Options.addon(map: config_flags, from: OPTIONS)
end
end
end
- def self.mixin(with: nil)
- addons = Mixin::Addons.options(with)
+ def self.mixin_module
+ Mixin
+ end
- mod = ::BCDD::Result::Mixin.module!
- mod.send(:include, Mixin::Methods)
- mod.send(:include, *addons) unless addons.empty?
- mod
+ def self.result_factory
+ ::BCDD::Result::Context
end
+
+ private_class_method :mixin_module, :result_factory
end