Class: Ecircle::Member

Inherits:
Base
  • Object
show all
Defined in:
lib/ecircle/member.rb

Instance Attribute Summary

Attributes inherited from Base

#all_fields, #id, #named_attrs

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#[], #init_with_xml, #method_missing

Constructor Details

#initialize(xml_string) ⇒ Member

Returns a new instance of Member.



9
10
11
12
# File 'lib/ecircle/member.rb', line 9

def initialize(xml_string)
  super()
  init_with_xml("member", xml_string)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Ecircle::Base

Class Method Details

.find_by_id(member_id) ⇒ Object



4
5
6
# File 'lib/ecircle/member.rb', line 4

def find_by_id(member_id)
  Ecircle.client.lookup_member_by_id :memberid => member_id
end

Instance Method Details

#deleteObject



14
15
16
# File 'lib/ecircle/member.rb', line 14

def delete
  Ecircle.client.delete_member :memberId => @id
end

#groupObject



23
24
25
# File 'lib/ecircle/member.rb', line 23

def group
  Ecircle::Group.find_by_id(group_id)
end

#group_idObject



21
# File 'lib/ecircle/member.rb', line 21

def group_id ; @id.split(/g/).last ; end

#userObject



26
27
28
# File 'lib/ecircle/member.rb', line 26

def user
  Ecircle::User.find_by_id(user_id)
end

#user_idObject

TODO with assume that the member id is the form of “<userid>g<groupid>”, hence TODO split on ‘g’ should work!



20
# File 'lib/ecircle/member.rb', line 20

def user_id  ; @id.split(/g/).first ; end