Sha256: 54ebf379b4a63b5c04e15c120fda306caf88ea8248d027abb9c55528595e53a1

Contents?: true

Size: 1.14 KB

Versions: 2

Compression:

Stored size: 1.14 KB

Contents

module JSONAPIonify::Structure
  module Maps
    class Relationships < Base

      # The value of the relationships key MUST be an object (a "relationships object"). Members of the relationships object ("relationships") represent references from the resource object in which it's defined to other resource objects.
      # Relationships may be to-one or to-many.

      # A relationship object that represents a to-many relationship MAY also contain pagination links under the links member, as described below.
      # A resource object's AttributesObject and its RelationshipsObject are collectively called its fields.
      # Fields for a ResourceObject **MUST** share a common namespace with each
      # other and with `type` and `id`. In other words, a resource can not have an
      # attribute and relationship with the same name, nor can it have an attribute
      # or relationship named `type` or `id`.
      must_not_contain! :type, :id
      validate_each! message: 'conflicts with a resource_key' do |obj, key, _|
        !obj.parent || !obj.parent.attribute_keys.include?(key)
      end

      value_is Objects::Relationship, strict: true

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jsonapionify-0.9.0 lib/jsonapionify/structure/maps/relationships.rb
jsonapionify-0.0.1.pre lib/jsonapionify/structure/maps/relationships.rb