lib/resultt.rb in resultt-0.1.0 vs lib/resultt.rb in resultt-1.0.0

- old
+ new

@@ -3,11 +3,12 @@ module Resultt class NilValueError < StandardError; end; def Result - success = Success.new yield + value = yield_all(yield) + success = Success.new(value) raise NilValueError, 'Resultt returned a nil value' if success.value.nil? success rescue StandardError => e Error.new(e) @@ -55,7 +56,15 @@ def ok? false end alias success? ok? + end + + private + + def yield_all(yielded) + return yield_all(yielded.call) if yielded.is_a? Proc + + yielded end end