Class: SmartCore::Operation::Result::Error::Set Private

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/smart_core/operation/result/error/set.rb

Overview

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

Since:

  • 0.1.0

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cases) ⇒ void

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.

Parameters:

Since:

  • 0.1.0



44
45
46
# File 'lib/smart_core/operation/result/error/set.rb', line 44

def initialize(cases)
  @cases = cases.freeze
end

Instance Attribute Details

#casesArray<SmartCore::Operation::Result::Error::Case> (readonly)

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.

Returns:

Since:

  • 0.1.0



37
38
39
# File 'lib/smart_core/operation/result/error/set.rb', line 37

def cases
  @cases
end

Class Method Details

.build(error_codes, error_context) ⇒ SmartCore::Operation::Result::Error::Set

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.

Parameters:

  • error_codes (Array<String, Symbol, Any>)
  • error_context (Hash<String|Symbol,Any>)

Returns:

Since:

  • 0.1.0



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/smart_core/operation/result/error/set.rb', line 16

def build(error_codes, error_context)
  error_cases =
    if error_codes.empty?
      [SmartCore::Operation::Result::Error::Case.new(context: error_context)]
    else
      error_codes.map do |error_code|
        SmartCore::Operation::Result::Error::Case.new(
          code: error_code,
          context: error_context
        )
      end
    end

  new(error_cases)
end

Instance Method Details

#codesArray<String|Symbol|Any>

Returns:

  • (Array<String|Symbol|Any>)

Since:

  • 0.1.0



52
53
54
# File 'lib/smart_core/operation/result/error/set.rb', line 52

def codes
  cases.map(&:code)
end

#contextHash<String|Symbol,Any>

Returns:

  • (Hash<String|Symbol,Any>)

Since:

  • 0.1.0



60
61
62
# File 'lib/smart_core/operation/result/error/set.rb', line 60

def context
  cases.sample.context
end

#each(&block) ⇒ void

This method returns an undefined value.

Since:

  • 0.1.0



68
69
70
# File 'lib/smart_core/operation/result/error/set.rb', line 68

def each(&block)
  cases.each(&block)
end