Class: JMESPath::Runtime Private
- Inherits:
-
Object
- Object
- JMESPath::Runtime
- Defined in:
- lib/jmespath/runtime.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- DEFAULT_PARSER =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
CachingParser
Instance Attribute Summary collapse
- #parser ⇒ Parser, CachingParser readonly private
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Runtime
constructor
private
Constructs a new runtime object for evaluating JMESPath expressions.
- #search(expression, data) ⇒ Mixed? private
Constructor Details
#initialize(options = {}) ⇒ Runtime
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.
Constructs a new runtime object for evaluating JMESPath expressions.
runtime = JMESPath::Runtime.new
runtime.search(expression, data)
#=> ...
## Caching
When constructing a JMESPath::Runtime, the default parser caches expressions. This significantly speeds up calls to #search multiple times with the same expression but different data. To disable caching, pass ‘:cache_expressions => false` to the constructor or pass a custom `:parser`.
45 46 47 |
# File 'lib/jmespath/runtime.rb', line 45 def initialize( = {}) @parser = [:parser] || default_parser() end |
Instance Attribute Details
#parser ⇒ Parser, CachingParser (readonly)
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.
50 51 52 |
# File 'lib/jmespath/runtime.rb', line 50 def parser @parser end |
Instance Method Details
#search(expression, data) ⇒ Mixed?
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.
55 56 57 58 |
# File 'lib/jmespath/runtime.rb', line 55 def search(expression, data) optimized_expression = @parser.parse(expression).optimize optimized_expression.visit(data) end |