Class: TinCanApi::StatementRef
- Inherits:
-
Object
- Object
- TinCanApi::StatementRef
- 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
-
#id ⇒ Object
Returns the value of attribute id.
-
#object_type ⇒ Object
Returns the value of attribute object_type.
Instance Method Summary collapse
-
#initialize(options = {}, &block) ⇒ StatementRef
constructor
A new instance of StatementRef.
- #serialize(version) ⇒ Object
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(={}, &block) @object_type = 'StatementRef' json = .fetch(:json, nil) if json attributes = JSON.parse(json) self.id = attributes['id'] if attributes['id'] else self.id = .fetch(:id, nil) if block_given? block[self] end end end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
6 7 8 |
# File 'lib/tin_can_api/statement_ref.rb', line 6 def id @id end |
#object_type ⇒ Object
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 |