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

- old
+ new

@@ -8,27 +8,32 @@ # A wrapper around the API response class Response < SimpleDelegator extend Forwardable # @!method dig(*key) - # Delegates to {Response#to_h} to extract a nested value specified by the - # sequence of keys - # @param [String] key + # Delegates to the Hash returned by {Response#to_h} to extract a nested + # value specified by the sequence of keys + # @param [String] key one or more keys # @see https://ruby-doc.org/core/Hash.html#method-i-dig def_delegator :to_h, :dig class << self + # @return [nil,.parse] an optional custom parser attr_accessor :parser end - def_delegator :to_h, :dig - + # @return [nil,.parse] an optional custom parser attr_writer :parser + # @!attribute [r] parser + # @return [nil,.parse] an optional custom parser def parser @parser || self.class.parser end + # Parses the response body + # + # @note Delegates to {#to_h} if no custom parser is set def parse parser ? parser.parse(body) : to_h end # Casts body to Hash