Class: TinCanApi::Group
Overview
Group model class
Instance Attribute Summary collapse
-
#members ⇒ Object
Returns the value of attribute members.
Attributes inherited from Agent
#account, #mbox, #mbox_sha1_sum, #name, #object_type, #open_id
Instance Method Summary collapse
-
#initialize(options = {}, &block) ⇒ Group
constructor
A new instance of Group.
- #serialize(version) ⇒ Object
Constructor Details
#initialize(options = {}, &block) ⇒ Group
Returns a new instance of Group.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/tin_can_api/group.rb', line 8 def initialize(={}, &block) super(, &block) @object_type = 'Group' @members = [] json = .fetch(:json, nil) if json attributes = JSON.parse(json) attributes['member'].each do |member| members << Agent.new(json: member.to_json) end else self.members = .fetch(:members, nil) if block_given? block[self] end end end |
Instance Attribute Details
#members ⇒ Object
Returns the value of attribute members.
6 7 8 |
# File 'lib/tin_can_api/group.rb', line 6 def members @members end |
Instance Method Details
#serialize(version) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/tin_can_api/group.rb', line 28 def serialize(version) node = super(version) if members.any? node['member'] = members.map {|member| member.serialize(version)} end node end |