Class: GroupOpenID::Client
- Inherits:
-
Object
- Object
- GroupOpenID::Client
- Defined in:
- lib/group_open_id/client.rb
Class Attribute Summary collapse
-
.app_key ⇒ Object
Returns the value of attribute app_key.
Instance Attribute Summary collapse
- #fetcher ⇒ Object
-
#user_key ⇒ Object
Returns the value of attribute user_key.
-
#user_openid ⇒ Object
Returns the value of attribute user_openid.
Instance Method Summary collapse
-
#initialize(user_openid = '', user_key = '') ⇒ Client
constructor
A new instance of Client.
- #member?(group, member) ⇒ Boolean
- #members(group) ⇒ Object
- #membership_location(group) ⇒ Object (also: #group_id?)
- #parse_members(doc) ⇒ Object
Constructor Details
#initialize(user_openid = '', user_key = '') ⇒ Client
Returns a new instance of Client.
12 13 14 |
# File 'lib/group_open_id/client.rb', line 12 def initialize(user_openid = '', user_key = '') @user_key, @user_openid = user_key, user_openid end |
Class Attribute Details
.app_key ⇒ Object
Returns the value of attribute app_key.
9 10 11 |
# File 'lib/group_open_id/client.rb', line 9 def app_key @app_key end |
Instance Attribute Details
#fetcher ⇒ Object
35 36 37 |
# File 'lib/group_open_id/client.rb', line 35 def fetcher @fetcher ||= Fetcher.new(self) end |
#user_key ⇒ Object
Returns the value of attribute user_key.
6 7 8 |
# File 'lib/group_open_id/client.rb', line 6 def user_key @user_key end |
#user_openid ⇒ Object
Returns the value of attribute user_openid.
6 7 8 |
# File 'lib/group_open_id/client.rb', line 6 def user_openid @user_openid end |
Instance Method Details
#member?(group, member) ⇒ Boolean
28 29 30 31 32 |
# File 'lib/group_open_id/client.rb', line 28 def member?(group, member) (url = membership_location(group)) or raise InvalidGroupID url += '?openid=' + CGI.escape(::URI.parse(member).normalize.to_s) fetcher.head(url)['x-myid-membership'].to_s == 'true' end |
#members(group) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/group_open_id/client.rb', line 21 def members(group) (url = membership_location(group)) or raise InvalidGroupID url += '?format=xml' p url parse_members(fetcher.get(url)) end |
#membership_location(group) ⇒ Object Also known as: group_id?
16 17 18 |
# File 'lib/group_open_id/client.rb', line 16 def membership_location(group) fetcher.head(group)['x-myid-membership-location'] end |
#parse_members(doc) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/group_open_id/client.rb', line 39 def parse_members(doc) Hpricot(doc).search('//relation').map do |rel| member = Member.new member.members.each{|sym| member.send("#{sym}=", rel.at(sym).inner_html)} member end end |