Class JMESPath::Runtime
In: lib/jmespath/runtime.rb
Parent: Object

@api private

Methods

new   search  

Constants

DEFAULT_PARSER = CachingParser   @api private

Attributes

parser  [R]  @return [Parser, CachingParser]

Public Class methods

Constructs a new runtime object for evaluating JMESPath expressions.

    runtime = JMESPath::Runtime.new
    runtime.search(expression, data)
    #=> ...

## Caching

When constructing a {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`.

@example Re-use a Runtime, caching enabled by default

  runtime = JMESPath::Runtime.new
  runtime.parser
  #=> #<JMESPath::CachingParser ...>

@example Disable caching

  runtime = JMESPath::Runtime.new(cache_expressions: false)
  runtime.parser
  #=> #<JMESPath::Parser ...>

@option options [Boolean] :cache_expressions (true) When `false`, a non

  caching parser will be used. When `true`, a shared instance of
  {CachingParser} is used.  Defaults to `true`.

@option options [Boolean] :disable_visit_errors (false) When `true`,

  no errors will be raised during runtime processing. Parse errors
  will still be raised, but unexpected data sent to visit will
  result in nil being returned.

@option options [Parser,CachingParser] :parser

Public Instance methods

@param [String<JMESPath>] expression @param [Hash] data @return [Mixed,nil]

[Validate]