lib/flows/result/err.rb in flows-0.3.0 vs lib/flows/result/err.rb in flows-0.4.0
- old
+ new
@@ -1,26 +1,32 @@
module Flows
class Result
- # Wrapper for failure results
+ # Result Object for failure results.
+ #
+ # @see Flows::Result behaviour described here
class Err < Result
- attr_reader :error
-
- def initialize(data, status: :failure, meta: {})
- @error = data
+ def initialize(data, status: :err, meta: {})
+ @data = data
@status = status
@meta = meta
end
+ def error
+ @data
+ end
+
+ # @return [false]
def ok?
false
end
+ # @return [true]
def err?
true
end
def unwrap
- raise UnwrapError.new(@status, @data, @meta)
+ raise AccessError, self
end
end
end
end