Class: GooglePlus::Activity
- Inherits:
-
Object
- Object
- GooglePlus::Activity
- Extended by:
- Resource
- Includes:
- Entity
- Defined in:
- lib/google_plus/activity.rb
Overview
An Acitity in Google Plus
Constant Summary
Constants included from Resource
Instance Attribute Summary
Attributes included from Entity
Class Method Summary collapse
-
.for_person(user_id, params = {}) ⇒ GooglePlus::Cursor
Get a list of activities from this person.
-
.get(activity_id, params = {}) ⇒ GooglePlus::Activity
Get an activity by ID.
-
.search(query, params = {}) ⇒ GooglePlus::Cursor
Search for an activity.
Instance Method Summary collapse
-
#initialize(hash) ⇒ GooglePlus::Activity
constructor
Load a new instance from an attributes hash Useful if you have the underlying response data for an object - Generally, what you want is #get though.
-
#list_comments ⇒ GooglePlus::Cursor
Get the list of comments for an activity.
-
#list_people(collection) ⇒ GooglePlus::Cursor
List the people of a certain type of action on this activity.
-
#person ⇒ GooglePlus::Person
get the actor of this activity.
-
#plusoners ⇒ GooglePlus::Cursor
List the people that plusone’d this activity.
-
#resharers ⇒ GooglePlus::Cursor
List the people that reshared this activity.
Methods included from Resource
Methods included from Entity
included, #method_missing, #respond_to?
Constructor Details
#initialize(hash) ⇒ GooglePlus::Activity
Load a new instance from an attributes hash Useful if you have the underlying response data for an object - Generally, what you want is #get though
83 84 85 |
# File 'lib/google_plus/activity.rb', line 83 def initialize(hash) load_hash(hash) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class GooglePlus::Entity
Class Method Details
.for_person(user_id, params = {}) ⇒ GooglePlus::Cursor
Get a list of activities from this person
41 42 43 44 45 |
# File 'lib/google_plus/activity.rb', line 41 def self.for_person(user_id, params = {}) collection = params[:collection] || :public resource = "people/#{user_id}/activities/#{collection}" GooglePlus::Cursor.new(self, :get, resource, params) end |
.get(activity_id, params = {}) ⇒ GooglePlus::Activity
Get an activity by ID
15 16 17 18 |
# File 'lib/google_plus/activity.rb', line 15 def self.get(activity_id, params = {}) data = make_request(:get, "activities/#{activity_id}", params) Activity.new(JSON.parse(data)) if data end |
.search(query, params = {}) ⇒ GooglePlus::Cursor
Search for an activity
26 27 28 29 30 31 |
# File 'lib/google_plus/activity.rb', line 26 def self.search(query, params = {}) params[:query] = query params[:orderBy] = params.delete(:order_by) if params.has_key?(:order_by) resource = 'activities' GooglePlus::Cursor.new(self, :get, resource, params) end |
Instance Method Details
#list_comments ⇒ GooglePlus::Cursor
Get the list of comments for an activity
49 50 51 |
# File 'lib/google_plus/activity.rb', line 49 def list_comments GooglePlus::Comment.for_activity(id) end |
#list_people(collection) ⇒ GooglePlus::Cursor
List the people of a certain type of action on this activity
62 63 64 65 |
# File 'lib/google_plus/activity.rb', line 62 def list_people(collection) resource = "activities/#{id}/people/#{collection}" GooglePlus::Cursor.new(GooglePlus::Person, :get, resource) end |
#person ⇒ GooglePlus::Person
get the actor of this activity
55 56 57 |
# File 'lib/google_plus/activity.rb', line 55 def person @person ||= GooglePlus::Person.get(actor.id) end |
#plusoners ⇒ GooglePlus::Cursor
List the people that plusone’d this activity
69 70 71 |
# File 'lib/google_plus/activity.rb', line 69 def plusoners list_people(:plusoners) end |
#resharers ⇒ GooglePlus::Cursor
List the people that reshared this activity
75 76 77 |
# File 'lib/google_plus/activity.rb', line 75 def resharers list_people(:resharers) end |