Method: Flows::Result#error

Defined in:
lib/flows/result.rb

#errorObject

This method is abstract.

Returns result data.

Returns:

  • (Object)

    result data

Raises:



166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/flows/result.rb', line 166

class Result
  # @return [Symbol] status of Result Object, default is `:ok` for successful results
  #   and `:err` for failure results.
  attr_reader :status

  # @return [Hash] metadata, don't use it to store business data
  attr_reader :meta

  # Direct creation of this abstract class is forbidden.
  #
  # @raise [StandardError] you will get an error
  def initialize(**)
    raise 'Use Flows::Result::Ok or Flows::Result::Err for build result objects'
  end

  # Results are equal if have same type and data.
  #
  # Metadata is ignored in comparison.
  #
  # @return [Boolean]
  def ==(other)
    return false if self.class != other.class

    (status == other.status) && (data == other.send(:data))
  end

  private

  attr_accessor :data
end