Class: Hanami::Interactor::Result

Inherits:
Utils::BasicObject
Defined in:
gems/gems/hanami-utils-1.3.0/lib/hanami/interactor.rb,
gems/gems/hanami-utils-1.3.6/lib/hanami/interactor.rb

Overview

Result of an operation

Since:

  • 0.3.5

Instance Method Summary collapse

Methods inherited from Utils::BasicObject

#class, #inspect, #instance_of?, #is_a?, #kind_of?, #object_id, #pretty_print, #respond_to?

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name) ⇒ Object (protected)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.3.5

def method_missing(method_name, *)
  @payload.fetch(method_name) { super }
end

Instance Method Details

#errornil, String

Returns the first errors collected during an operation

Returns:

  • (nil, String)

    the error, if present

See Also:

Since:

  • 0.3.5

def error
  errors.first
end

#errorsArray

Returns all the errors collected during an operation

Returns:

  • (Array)

    the errors

See Also:

Since:

  • 0.3.5

def errors
  @errors.dup
end

#fail!Object

Forces the status to be a failure

Since:

  • 0.3.5

def fail!
  @success = false
end

#failure?TrueClass, FalseClass

Checks if the current status is not successful

Returns:

  • (TrueClass, FalseClass)

    the result of the check

Since:

  • 0.9.2

def failure?
  !successful?
end

#successful?TrueClass, FalseClass Also known as: success?

Checks if the current status is successful

Returns:

  • (TrueClass, FalseClass)

    the result of the check

Since:

  • 0.8.1

def successful?
  @success && errors.empty?
end