class JSONAPIHelpers::Serializers::Relationships
Public Class Methods
new()
click to toggle source
# File lib/jsonapi_helpers/serializers/relationships.rb, line 8 def initialize @relationships = {} end
Public Instance Methods
add(relation:, id:, type:)
click to toggle source
# File lib/jsonapi_helpers/serializers/relationships.rb, line 12 def add(relation:, id:, type:) @relationships[relation] = { id: id, type: type } end
to_h()
click to toggle source
# File lib/jsonapi_helpers/serializers/relationships.rb, line 16 def to_h @relationships end
to_json(_context = nil)
click to toggle source
Rails is awkward and calls to_json
with a context argument NOTE: Rails only method Hash#to_json
# File lib/jsonapi_helpers/serializers/relationships.rb, line 22 def to_json(_context = nil) to_h.to_json end