Class: Janeway::Interpreters::NameSelectorInterpreter
- Defined in:
- lib/janeway/interpreters/name_selector_interpreter.rb
Overview
Interprets a name selector, returns results or forwards them to next selector
Filters the input by returning the key that has the given name.
Must differentiate between a null value of a key that exists (nil) and a key that does not exist ([])
Constant Summary
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#interpret(input, root) ⇒ Object
Interpret selector on the given input.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Janeway::Interpreters::Base
Instance Method Details
#interpret(input, root) ⇒ Object
Interpret selector on the given input.
19 20 21 22 23 24 25 26 27 |
# File 'lib/janeway/interpreters/name_selector_interpreter.rb', line 19 def interpret(input, root) return [] unless input.is_a?(Hash) && input.key?(selector.name) result = input[selector.name] return [result] unless @next # Forward result to next selector @next.interpret(result, root) end |