class Copper::Functions::Fetch

Public Instance Methods

value(vars = {}) click to toggle source
# File lib/copper/functions/fetch.rb, line 9
def value(vars = {})
        key = elements[0].value(vars)
        context = vars[:context]

        begin
                path = JsonPath.new(key)
                result = path.on(context)
        rescue ArgumentError => exc
                raise ParseError, "JSONPath error #{key}: #{exc.message}"
        rescue NoMethodError => exc
                raise ParseError, "JSONPath error #{key}. Invalid JSONPath"
        end

        return handle_attributes(result, vars)
end