Sha256: 2c4c86e825925f22d98935a4f980655bacc817b06ec805481bb369e7f5d4c8fe
Contents?: true
Size: 652 Bytes
Versions: 12
Compression:
Stored size: 652 Bytes
Contents
# frozen_string_literal: true module JSONAPI class Document # A jsonapi resource identifier class ResourceId attr_accessor :type, :id # @param type [String | Symbol] The type of the resource identifier # @param id [String | Symbol] The id of the resource identifier def initialize(type:, id:) @type = type.to_s @id = id.to_s end # Represents ResourceId as a JSON parsable string def to_s "{ \"type\": \"#{@type}\", \"id\": \"#{@id}\" }" end # Represents ResourceID as a jsonapi hash def to_h { type: @type, id: @id } end end end end
Version data entries
12 entries across 12 versions & 1 rubygems