Class: TinCanApi::Activity
- Inherits:
-
Object
- Object
- TinCanApi::Activity
- Defined in:
- lib/tin_can_api/activity.rb
Overview
Activity model class
Instance Attribute Summary collapse
-
#definition ⇒ Object
Returns the value of attribute definition.
-
#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) ⇒ Activity
constructor
A new instance of Activity.
- #serialize(version) ⇒ Object
Constructor Details
#initialize(options = {}, &block) ⇒ Activity
Returns a new instance of Activity.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/tin_can_api/activity.rb', line 9 def initialize(={}, &block) @object_type = 'Activity' json = .fetch(:json, nil) if json attributes = JSON.parse(json) self.id = Addressable::URI.parse(attributes['id']) if attributes['id'] self.definition = ActivityDefinition.new(json: attributes['definition'].to_json) if attributes['definition'] else self.id = .fetch(:id, nil) self.definition = .fetch(:definition, nil) if block_given? block[self] end end end |
Instance Attribute Details
#definition ⇒ Object
Returns the value of attribute definition.
6 7 8 |
# File 'lib/tin_can_api/activity.rb', line 6 def definition @definition end |
#id ⇒ Object
Returns the value of attribute id.
7 8 9 |
# File 'lib/tin_can_api/activity.rb', line 7 def id @id end |
#object_type ⇒ Object
Returns the value of attribute object_type.
6 7 8 |
# File 'lib/tin_can_api/activity.rb', line 6 def object_type @object_type end |
Instance Method Details
#serialize(version) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/tin_can_api/activity.rb', line 33 def serialize(version) node = {} node['id'] = id.to_s if id node['definition'] = definition.serialize(version) if definition node end |