Class: SmartCore::Operation::Result::Error::Case

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

Overview

Since:

  • 0.1.0

Instance Method Summary collapse

Constructor Details

#initialize(code: SmartCore::Operation::Result::Error::Code::EMPTY_CODE, context: SmartCore::Operation::Result::Error::Context::EMPTY_CONTEXT) ⇒ 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:

  • code (String, Symbol, Any) (defaults to: SmartCore::Operation::Result::Error::Code::EMPTY_CODE)
  • context (Hash, Any) (defaults to: SmartCore::Operation::Result::Error::Context::EMPTY_CONTEXT)

Since:

  • 0.1.0



12
13
14
15
16
17
18
# File 'lib/smart_core/operation/result/error/case.rb', line 12

def initialize(
  code: SmartCore::Operation::Result::Error::Code::EMPTY_CODE,
  context: SmartCore::Operation::Result::Error::Context::EMPTY_CONTEXT
)
  @code = SmartCore::Operation::Result::Error::Code.new(code)
  @context = SmartCore::Operation::Result::Error::Context.new(context)
end

Instance Method Details

#codeString, ...

Returns:

  • (String, Symbol, NilClass, Any)

Since:

  • 0.1.0



24
25
26
# File 'lib/smart_core/operation/result/error/case.rb', line 24

def code
  @code.identifier
end

#contextHash

Returns:

  • (Hash)

Since:

  • 0.1.0



32
33
34
# File 'lib/smart_core/operation/result/error/case.rb', line 32

def context
  @context.data
end

#to_hHash<Synbol,Any>

Returns:

  • (Hash<Synbol,Any>)

Since:

  • 0.1.0



40
41
42
# File 'lib/smart_core/operation/result/error/case.rb', line 40

def to_h
  { code: code, context: context }
end