Sha256: 32a7038fd86ae7a39eb6928280d5719672169104168221f77a992083b668e06a

Contents?: true

Size: 508 Bytes

Versions: 1

Compression:

Stored size: 508 Bytes

Contents

# frozen_string_literal: true

require "ostruct"

module SecurityTrails
  class Response < OpenStruct
    def openstruct_to_hash(object, hash = {})
      object.each_pair do |key, value|
        hash[key] = case value
                    when OpenStruct then openstruct_to_hash(value)
                    when Array then value.map { |v| openstruct_to_hash(v) }
                    else value
                    end
      end
      hash
    end

    def to_h
      openstruct_to_hash(self)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
securitytrails-0.1.4 lib/securitytrails/response.rb