Sha256: bfdd63b28c9f2007ff014be4956e0d098ed9f21b5f95bdeeb21dbff0760ea7a7

Contents?: true

Size: 512 Bytes

Versions: 1

Compression:

Stored size: 512 Bytes

Contents

# frozen_string_literal: true

require 'delegate'
require 'forwardable'
require 'json'

module Vacuum
  # 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
    #   @see Hash#dig
    def_delegator :to_h, :dig

    # Casts body to Hash
    # @return [Hash]
    def to_h
      JSON.parse(body)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vacuum-3.0.0 lib/vacuum/response.rb