File: databasedotcom/chatter/feed_item.rb

Overview
Module Structure
Class Hierarchy
Code

Overview

Module Structure

  module: <Toplevel Module>
  module: Databasedotcom#3
  module: Chatter#4
  class: FeedItem#7
inherits from
  Record ( Databasedotcom::Chatter )
has properties
method: comments #10
method: likes #16
method: like #22
method: comment / 1 #28
class method: collection_from_response / 1 #35

Class Hierarchy

Code

   1  require 'databasedotcom/chatter/record'
   2 
   3  module Databasedotcom
   4    module Chatter
   5 
   6      # An item in a Feed.
   7      class FeedItem < Record
   8 
   9        # Returns a Collection of comments that were posted on this FeedItem instance.
  10        def comments
  11          collection = Databasedotcom::Collection.new(self.client, self.raw_hash["comments"]["total"], self.raw_hash["comments"]["nextPageUrl"], nil, self.raw_hash["comments"]["currentPageUrl"])
  12          collection.concat(self.raw_hash["comments"]["comments"])
  13        end
  14 
  15        # Returns a Collection of likes for this FeedItem instance.
  16        def likes
  17          collection = Databasedotcom::Collection.new(self.client, self.raw_hash["likes"]["total"], self.raw_hash["likes"]["nextPageUrl"], self.raw_hash["likes"]["previousPageUrl"], self.raw_hash["likes"]["currentPageUrl"])
  18          collection.concat(self.raw_hash["likes"]["likes"])
  19        end
  20 
  21        # Like this FeedItem.
  22        def like
  23          result = self.client.http_post("/services/data/v#{self.client.version}/chatter/feed-items/#{self.id}/likes")
  24          Like.new(self.client, result.body)
  25        end
  26 
  27        # Post a Comment on this FeedItem with content _text_.
  28        def comment(text)
  29          result = self.client.http_post("/services/data/v#{self.client.version}/chatter/feed-items/#{self.id}/comments", nil, :text => text)
  30          Comment.new(self.client, result.body)
  31        end
  32 
  33        protected
  34 
  35        def self.collection_from_response(response)
  36          response["items"]
  37        end
  38      end
  39    end
  40  en