Class: JMESPath::CachingParser

Inherits:
Object
  • Object
show all
Defined in:
lib/jmespath/caching_parser.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ CachingParser

Returns a new instance of CachingParser.



6
7
8
9
10
# File 'lib/jmespath/caching_parser.rb', line 6

def initialize(options = {})
  @parser = options[:parser] || Parser.new(options)
  @mutex = Mutex.new
  @cache = {}
end

Instance Method Details

#parse(expression) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/jmespath/caching_parser.rb', line 12

def parse(expression)
  if cached = @cache[expression]
    cached
  else
    cache_expression(expression)
  end
end