Class: Yammer::Resources::Thread

Inherits:
Base
  • Object
show all
Defined in:
lib/yammer/resources/thread.rb

Instance Attribute Summary

Attributes inherited from Base

#attrs, #id

Instance Method Summary collapse

Methods inherited from Base

#api_handler, attr_accessor_deffered, base_name, #base_name, #changes, #delete!, fetch, get, identity_map, #initialize, #load!, #load_deferred_attribute!, #loaded?, model_attributes, #modified?, #new_record?, #persisted?, #reload!, #save, #update

Methods included from ApiHandler

#api_handler, #establish_api_handler

Constructor Details

This class inherits a constructor from Yammer::Resources::Base

Instance Method Details

#first_replyObject


27
28
29
# File 'lib/yammer/resources/thread.rb', line 27

def first_reply
  @first_reply ||= first_reply_id ? Yammer::Resources::Message.new(:id => first_reply_id) : nil
end

#first_reply_idObject


23
24
25
# File 'lib/yammer/resources/thread.rb', line 23

def first_reply_id
  stats[:first_reply_id]
end

#last_replyObject


35
36
37
# File 'lib/yammer/resources/thread.rb', line 35

def last_reply
  @latest_reply ||= latest_reply_id ? Yammer::Resources::Message.new(:id => latest_reply_id) : nil
end

#latest_reply_idObject


31
32
33
# File 'lib/yammer/resources/thread.rb', line 31

def latest_reply_id
  stats[:latest_reply_id]
end

#messagesObject


49
50
51
52
53
54
55
56
57
# File 'lib/yammer/resources/thread.rb', line 49

def messages
  @messages = {}
  result = api_handler.messages_in_thread(self.id)
  msgs = result.body[:messages].each do |message|
    msg = Yammer::Resources::Message.new(message)
    @messages["#{msg.id}"] = msg
  end
  @messages
end

#peopleObject


39
40
41
42
43
44
45
46
47
# File 'lib/yammer/resources/thread.rb', line 39

def people
  @people ||= begin
    @participants.map do |part|
      next unless part[:type] == 'user'
      Yammer::Resources::User.new(:id => part[:id])
    end
  end
  @people
end