Class: NxtSchema::Node::ErrorStore

Inherits:
Hash
  • Object
show all
Defined in:
lib/nxt_schema/node/error_store.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ ErrorStore

Returns a new instance of ErrorStore.



4
5
6
7
# File 'lib/nxt_schema/node/error_store.rb', line 4

def initialize(node)
  super()
  @node = node
end

Instance Attribute Details

#nodeObject (readonly)

Returns the value of attribute node.



9
10
11
# File 'lib/nxt_schema/node/error_store.rb', line 9

def node
  @node
end

Instance Method Details

#add_error(node, error) ⇒ Object



35
36
37
38
# File 'lib/nxt_schema/node/error_store.rb', line 35

def add_error(node, error)
  self[node.error_key] ||= []
  self[node.error_key] << error
end

#add_schema_error(message:) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/nxt_schema/node/error_store.rb', line 11

def add_schema_error(message:)
  add_error(
    node,
    NxtSchema::Node::Errors::SchemaError.new(
      node: node,
      message: message
    )
  )
end

#add_validation_error(message:) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/nxt_schema/node/error_store.rb', line 21

def add_validation_error(message:)
  add_error(
    node,
    NxtSchema::Node::Errors::ValidationError.new(
      node: node,
      message: message
    )
  )
end

#merge_errors(node) ⇒ Object



31
32
33
# File 'lib/nxt_schema/node/error_store.rb', line 31

def merge_errors(node)
  merge!(node.errors)
end