Class: TinCanApi::AgentAccount

Inherits:
Object
  • Object
show all
Defined in:
lib/tin_can_api/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/tin_can_api/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.home_page = attributes['homePage'] if attributes['homePage']
  else
    self.home_page = options.fetch(:home_page, nil)
    self.name =options.fetch(:name, nil)

    if block_given?
      block[self]
    end
  end
end

Instance Attribute Details

#home_pageObject

Returns the value of attribute home_page.



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

def home_page
  @home_page
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

Instance Method Details

#serialize(version) ⇒ Object



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

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