lib/jsonpath.rb in jsonpath-0.3.2 vs lib/jsonpath.rb in jsonpath-0.3.3
- old
+ new
@@ -4,11 +4,12 @@
class JsonPath
attr_reader :path
- def initialize(path)
+ def initialize(path, opts = nil)
+ @opts = opts
scanner = StringScanner.new(path)
@path = []
bracket_count = 0
while not scanner.eos?
if token = scanner.scan(/\$/)
@@ -51,13 +52,13 @@
def first(object)
enum_on(object).first
end
def enum_on(object)
- JsonPath::Enumerable.new(self, object)
+ JsonPath::Enumerable.new(self, object, @opts)
end
- def self.on(object, path)
- self.new(path).on(object)
+ def self.on(object, path, opts = nil)
+ self.new(path, opts).on(object)
end
end