Class: Core::Boundary::Result

Inherits:
Object
  • Object
show all
Includes:
Is::Inspectable
Defined in:
lib/core/boundary/result.rb

Overview

public

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeResult

Returns a new instance of Result.



15
16
17
18
# File 'lib/core/boundary/result.rb', line 15

def initialize
  @values = {}
  @errors = Errors.new
end

Instance Attribute Details

#valuesObject (readonly)

public


22
23
24
# File 'lib/core/boundary/result.rb', line 22

def values
  @values
end

Instance Method Details

#[]=(key, value) ⇒ Object

public


48
49
50
# File 'lib/core/boundary/result.rb', line 48

def []=(key, value)
  @values[key.to_sym] = value
end

#error?(*path) ⇒ Boolean

public

Returns:

  • (Boolean)


26
27
28
# File 'lib/core/boundary/result.rb', line 26

def error?(*path)
  @errors.any?(*path)
end

#errors(*path) ⇒ Object

public


38
39
40
41
42
43
44
# File 'lib/core/boundary/result.rb', line 38

def errors(*path)
  if path.any?
    @errors.for(*path)
  else
    @errors
  end
end

#finalizeObject



52
53
54
55
# File 'lib/core/boundary/result.rb', line 52

def finalize
  freeze
  self
end

#freezeObject



57
58
59
60
61
# File 'lib/core/boundary/result.rb', line 57

def freeze
  @arguments.freeze
  @values.freeze
  super
end

#success?(*path) ⇒ Boolean

public

Returns:

  • (Boolean)


32
33
34
# File 'lib/core/boundary/result.rb', line 32

def success?(*path)
  @errors.empty?(*path)
end