Class: TinCanApi::InteractionComponent
- Inherits:
-
Object
- Object
- TinCanApi::InteractionComponent
- Defined in:
- lib/tin_can_api/interaction_component.rb
Overview
InteractionComponent Class Description
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#id ⇒ Object
Returns the value of attribute id.
Instance Method Summary collapse
-
#initialize(options = {}, &block) ⇒ InteractionComponent
constructor
A new instance of InteractionComponent.
- #serialize(version) ⇒ Object
Constructor Details
#initialize(options = {}, &block) ⇒ InteractionComponent
Returns a new instance of InteractionComponent.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/tin_can_api/interaction_component.rb', line 8 def initialize(={}, &block) json = .fetch(:json, nil) if json attributes = JSON.parse(json) self.id = attributes['id'] if attributes['id'] self.description = attributes['description'] if attributes['description'] else self.id = .fetch(:id, nil) self.description = .fetch(:description, nil) if block_given? block[self] end end end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
6 7 8 |
# File 'lib/tin_can_api/interaction_component.rb', line 6 def description @description end |
#id ⇒ Object
Returns the value of attribute id.
6 7 8 |
# File 'lib/tin_can_api/interaction_component.rb', line 6 def id @id end |
Instance Method Details
#serialize(version) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/tin_can_api/interaction_component.rb', line 24 def serialize(version) node = {} node['id'] = id if id node['description'] = description if description node end |