Class: Unit::Types::Relationship

Inherits:
Object
  • Object
show all
Defined in:
lib/unit/types/relationship.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, type) ⇒ Relationship

Returns a new instance of Relationship.

Parameters:

  • The id of the relationship

  • The type



11
12
13
14
# File 'lib/unit/types/relationship.rb', line 11

def initialize(id, type)
  @id = id
  @type = type
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



7
8
9
# File 'lib/unit/types/relationship.rb', line 7

def id
  @id
end

#typeObject

Returns the value of attribute type.



7
8
9
# File 'lib/unit/types/relationship.rb', line 7

def type
  @type
end

Instance Method Details

#represent(nested: true) ⇒ Object

Parameters:

  • (defaults to: true)

    Whether or not the relationship is nested



17
18
19
# File 'lib/unit/types/relationship.rb', line 17

def represent(nested: true)
  nested ? { "data": { "id": id, "type": type } } : { "id": id, "type": type }
end