Class: Xapi::AgentAccount

Inherits:
Object
  • Object
show all
Defined in:
lib/xapi/agent_account.rb

Overview

Agent Account model class

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}, &block) ⇒ AgentAccount

Returns a new instance of AgentAccount.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/xapi/agent_account.rb', line 9

def initialize(options={}, &block)
  json = options.fetch(:json, nil)
  if json
    attributes = JSON.parse(json)
    self.name = attributes['name'] if attributes['name']
    self.homePage = attributes['homePage'] if attributes['homePage']
  else
    self.homePage = options.fetch(:home_page, nil)
    self.name =options.fetch(:name, nil)

    if block_given?
      block[self]
    end
  end
end

Instance Attribute Details

#homePageObject

Returns the value of attribute homePage.



7
8
9
# File 'lib/xapi/agent_account.rb', line 7

def homePage
  @homePage
end

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/xapi/agent_account.rb', line 7

def name
  @name
end

Instance Method Details

#serialize(version) ⇒ Object



25
26
27
28
29
30
# File 'lib/xapi/agent_account.rb', line 25

def serialize(version)
  node = {}
  node['name'] = name if name
  node['homePage'] = homePage if homePage
  node
end