Class: Janeway::Interpreters::NameSelectorDeleter

Inherits:
NameSelectorInterpreter show all
Defined in:
lib/janeway/interpreters/name_selector_deleter.rb

Overview

Interprets a name selector, and deletes the matched values.

Constant Summary

Constants inherited from Base

Base::NOTHING

Instance Attribute Summary

Attributes inherited from NameSelectorInterpreter

#name

Attributes inherited from Base

#next, #node

Instance Method Summary collapse

Methods inherited from NameSelectorInterpreter

#initialize

Methods inherited from Base

#initialize, #selector, #to_s, #type

Constructor Details

This class inherits a constructor from Janeway::Interpreters::NameSelectorInterpreter

Instance Method Details

#as_jsonHash

Return hash representation of this interpreter

Returns:

  • (Hash)


22
23
24
# File 'lib/janeway/interpreters/name_selector_deleter.rb', line 22

def as_json
  { type: type, value: name, next: @next&.as_json }
end

#interpret(input, _parent, _root, _path) ⇒ Object

Interpret selector on the given input.

Parameters:

  • input (Array, Hash)

    the results of processing so far

  • _parent (Array, Hash)

    parent of the input object

  • _root (Array, Hash)

    the entire input

  • _path (Array<String>)

    elements of normalized path to the current input



14
15
16
17
18
# File 'lib/janeway/interpreters/name_selector_deleter.rb', line 14

def interpret(input, _parent, _root, _path)
  return [] unless input.is_a?(Hash) && input.key?(name)

  [input.delete(name)]
end