Class: TinCanApi::StatementRef

Inherits:
Object
  • Object
show all
Defined in:
lib/tin_can_api/statement_ref.rb

Overview

StatementRef Class used when referencing another statement from a statement’s object property

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}, &block) ⇒ StatementRef

Returns a new instance of StatementRef.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/tin_can_api/statement_ref.rb', line 8

def initialize(options={}, &block)
  @object_type = 'StatementRef'
  json = options.fetch(:json, nil)
  if json
    attributes = JSON.parse(json)
    self.id = attributes['id'] if attributes['id']
  else
    self.id = options.fetch(:id, nil)

    if block_given?
      block[self]
    end
  end
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



6
7
8
# File 'lib/tin_can_api/statement_ref.rb', line 6

def id
  @id
end

#object_typeObject

Returns the value of attribute object_type.



6
7
8
# File 'lib/tin_can_api/statement_ref.rb', line 6

def object_type
  @object_type
end

Instance Method Details

#serialize(version) ⇒ Object



23
24
25
26
27
28
# File 'lib/tin_can_api/statement_ref.rb', line 23

def serialize(version)
  node = {}
  node['id'] = id if id
  node['objectType'] = object_type
  node
end