class TinCanApi::Activity

Activity model class

Attributes

definition[RW]
id[R]
object_type[RW]

Public Class Methods

new(options={}, &block) click to toggle source
# File lib/tin_can_api/activity.rb, line 9
def initialize(options={}, &block)
  @object_type = 'Activity'
  json = options.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 = options.fetch(:id, nil)
    self.definition = options.fetch(:definition, nil)
    if block_given?
      block[self]
    end
  end
end

Public Instance Methods

id=(value) click to toggle source
# File lib/tin_can_api/activity.rb, line 25
def id=(value)
  if value.is_a?(String)
    @id = Addressable::URI.parse(value)
  else
    @id = value
  end
end
serialize(version) click to toggle source
# 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