lib/vacuum/response.rb in vacuum-3.1.0 vs lib/vacuum/response.rb in vacuum-3.2.0

- old
+ new

@@ -14,9 +14,25 @@ # sequence of keys # @param [String] key # @see https://ruby-doc.org/core/Hash.html#method-i-dig def_delegator :to_h, :dig + class << self + attr_accessor :parser + end + + def_delegator :to_h, :dig + + attr_writer :parser + + def parser + @parser || self.class.parser + end + + def parse + parser ? parser.parse(body) : to_h + end + # Casts body to Hash # @return [Hash] def to_h JSON.parse(body) end