class JSONAPI::Document::ResourceId
A jsonapi resource identifier
Attributes
id[RW]
type[RW]
Public Class Methods
new(type:, id:)
click to toggle source
@param type [String | Symbol] The type of the resource identifier @param id [String | Symbol] The id of the resource identifier
# File lib/easy/jsonapi/document/resource_id.rb, line 12 def initialize(type:, id:) @type = type.to_s @id = id.to_s end
Public Instance Methods
to_h()
click to toggle source
Represents ResourceID as a jsonapi hash
# File lib/easy/jsonapi/document/resource_id.rb, line 23 def to_h { type: @type, id: @id } end
to_s()
click to toggle source
Represents ResourceId
as a JSON parsable string
# File lib/easy/jsonapi/document/resource_id.rb, line 18 def to_s "{ \"type\": \"#{@type}\", \"id\": \"#{@id}\" }" end