Class: SmartCore::Operation::Result::Error::Set Private
- Inherits:
-
Object
- Object
- SmartCore::Operation::Result::Error::Set
- 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.
Instance Attribute Summary collapse
- #cases ⇒ Array<SmartCore::Operation::Result::Error::Case> readonly private
Class Method Summary collapse
Instance Method Summary collapse
- #codes ⇒ Array<String|Symbol|Any>
- #context ⇒ Hash<String|Symbol,Any>
- #each(&block) ⇒ void
- #initialize(cases) ⇒ void constructor private
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.
44 45 46 |
# File 'lib/smart_core/operation/result/error/set.rb', line 44 def initialize(cases) @cases = cases.freeze end |
Instance Attribute Details
#cases ⇒ Array<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.
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.
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
#codes ⇒ Array<String|Symbol|Any>
52 53 54 |
# File 'lib/smart_core/operation/result/error/set.rb', line 52 def codes cases.map(&:code) end |
#context ⇒ Hash<String|Symbol,Any>
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.
68 69 70 |
# File 'lib/smart_core/operation/result/error/set.rb', line 68 def each(&block) cases.each(&block) end |