Class: OpenSocial::FetchGroupsRequest

Inherits:
Request
  • Object
show all
Defined in:
lib/opensocial/group.rb

Overview

Provides the ability to request a Collection of groups for a given user.

The FetchGroupsRequest wraps a simple request to an OpenSocial endpoint for a collection of groups. As parameters, it accepts a user ID. This request may be used, standalone, by calling send, or bundled into an RpcRequest.

Constant Summary collapse

SERVICE =

Defines the service fragment for use in constructing the request URL or JSON

"groups"

Constants inherited from Request

Request::GET

Instance Attribute Summary

Attributes inherited from Request

#connection, #guid, #key, #pid, #selector

Instance Method Summary collapse

Methods inherited from Request

#send_request

Constructor Details

#initialize(connection = nil, guid = "@me") ⇒ FetchGroupsRequest

Initializes a request to fetch groups for the specified user, or the default (@me). A valid Connection is not necessary if the request is to be used as part of an RpcRequest.



62
63
64
# File 'lib/opensocial/group.rb', line 62

def initialize(connection = nil, guid = "@me")
  super
end

Instance Method Details

#sendObject

Sends the request, passing in the appropriate SERVICE and specified instance variables.



68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/opensocial/group.rb', line 68

def send
  json = send_request(SERVICE, @guid)

  groups = Collection.new

  json["entry"].each do |entry|
    group = Group.new(entry)
    groups[group.id] = group
  end

  return groups
end