class Xapi::Activity

Activity model class

Attributes

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

Public Class Methods

new(options={}, &block) click to toggle source
# File lib/xapi/activity.rb, line 9
def initialize(options={}, &block)
  @object_type = 'Activity'
  json = options.fetch(:json, nil)
  if json
    attributes = JSON.parse(json)
    self.id =  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/xapi/activity.rb, line 25
def id=(value)
  @id = value
end
serialize(version) click to toggle source
# File lib/xapi/activity.rb, line 29
def serialize(version)
  node = {}
  node['id'] = id.to_s if id
  node['definition'] = definition.serialize(version) if definition
  node
end