Class: JMESPath::CachingParser
- Inherits:
-
Object
- Object
- JMESPath::CachingParser
- Defined in:
- lib/jmespath/caching_parser.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ CachingParser
constructor
A new instance of CachingParser.
- #parse(expression) ⇒ Object
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( = {}) @parser = [:parser] || Parser.new() @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 |