Module: SimpleResult

Defined in:
lib/simple_result.rb,
lib/simple_result/helpers.rb,
lib/simple_result/version.rb

Defined Under Namespace

Modules: Helpers Classes: Failure, Success

Constant Summary collapse

ResponseError =
Class.new(StandardError)
ErrorNotPresentOnSuccess =
Class.new(ResponseError)
PayloadNotPresentOnFailure =
Class.new(ResponseError)
NotImplemented =
Class.new(ResponseError)
Response =
Data.define(:payload, :error) do
  def initialize(payload: nil, error: nil) = super

  def success? = raise NotImplemented, 'success? not implemented'
  def failure? = raise NotImplemented, 'failure? not implemented'
  def payload_or_fallback(&) = payload || yield
  def and_then(&) = raise NotImplementedError, 'and_then not implemented'
end
VERSION =
'0.3.1'