Class: TinCanApi::Agent
- Inherits:
-
Object
- Object
- TinCanApi::Agent
- Defined in:
- lib/tin_can_api/agent.rb
Overview
Agent model class
Direct Known Subclasses
Instance Attribute Summary collapse
-
#account ⇒ Object
Returns the value of attribute account.
-
#mbox ⇒ Object
Returns the value of attribute mbox.
-
#mbox_sha1_sum ⇒ Object
Returns the value of attribute mbox_sha1_sum.
-
#name ⇒ Object
Returns the value of attribute name.
-
#object_type ⇒ Object
Returns the value of attribute object_type.
-
#open_id ⇒ Object
Returns the value of attribute open_id.
Instance Method Summary collapse
-
#initialize(options = {}, &block) ⇒ Agent
constructor
A new instance of Agent.
- #serialize(version) ⇒ Object
Constructor Details
#initialize(options = {}, &block) ⇒ Agent
Returns a new instance of Agent.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/tin_can_api/agent.rb', line 9 def initialize(={}, &block) @object_type = 'Agent' json = .fetch(:json, nil) if json attributes = JSON.parse(json) self.name = attributes['name'] if attributes['name'] self.mbox = attributes['mbox'] if attributes['mbox'] self.mbox_sha1_sum = attributes['mbox_sha1sum'] if attributes['mbox_sha1sum'] self.open_id = attributes['openid'] if attributes['openid'] self.account = AgentAccount.new(json: attributes['account'].to_json) if attributes['account'] else self.name = .fetch(:name, nil) self.mbox = .fetch(:mbox, nil) self.mbox_sha1_sum = .fetch(:mbox_sha1_sum, nil) self.open_id = .fetch(:open_id, nil) self.account = .fetch(:account, nil) if block_given? block[self] end end end |
Instance Attribute Details
#account ⇒ Object
Returns the value of attribute account.
7 8 9 |
# File 'lib/tin_can_api/agent.rb', line 7 def account @account end |
#mbox ⇒ Object
Returns the value of attribute mbox.
7 8 9 |
# File 'lib/tin_can_api/agent.rb', line 7 def mbox @mbox end |
#mbox_sha1_sum ⇒ Object
Returns the value of attribute mbox_sha1_sum.
7 8 9 |
# File 'lib/tin_can_api/agent.rb', line 7 def mbox_sha1_sum @mbox_sha1_sum end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/tin_can_api/agent.rb', line 7 def name @name end |
#object_type ⇒ Object
Returns the value of attribute object_type.
7 8 9 |
# File 'lib/tin_can_api/agent.rb', line 7 def object_type @object_type end |
#open_id ⇒ Object
Returns the value of attribute open_id.
7 8 9 |
# File 'lib/tin_can_api/agent.rb', line 7 def open_id @open_id end |
Instance Method Details
#serialize(version) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/tin_can_api/agent.rb', line 32 def serialize(version) node = {} node['objectType'] = object_type node['name'] = name if name node['mbox'] = mbox if mbox node['mbox_sha1sum'] = mbox_sha1_sum if mbox_sha1_sum node['openid'] = open_id if open_id node['account'] = account.serialize(version) if account node end |