Class: ErpIntegration::Resources::Errors

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/erp_integration/resources/errors.rb

Overview

The ‘ErpIntegration::Resources::Errors` expose a clean, simple API to manage and display error messages for any `ErpIntegration::Resource` instance.

Instance Method Summary collapse

Constructor Details

#initializeErrors

Returns a new instance of Errors.



13
14
15
# File 'lib/erp_integration/resources/errors.rb', line 13

def initialize
  @errors = []
end

Instance Method Details

#add(message) ⇒ String

Allows adding new error messages to the ‘ErpIntegration::Resource`.

Parameters:

  • message (String)

    An (internal/external) error message.

Returns:

  • (String)

    The given error message.

Raises:



20
21
22
23
24
25
# File 'lib/erp_integration/resources/errors.rb', line 20

def add(message)
  raise ErpIntegration::Error, 'Use a simple string as an error message' unless message.is_a?(String)

  @errors << message
  message
end

#each(&block) ⇒ Object



27
28
29
# File 'lib/erp_integration/resources/errors.rb', line 27

def each(&block)
  @errors.each(&block)
end