Module: FbGraph2::Edge::Messages

Included in:
Conversation, Thread
Defined in:
lib/fb_graph2/edge/messages.rb

Instance Method Summary collapse

Instance Method Details

#assign(attributes) ⇒ Object



4
5
6
7
8
9
# File 'lib/fb_graph2/edge/messages.rb', line 4

def assign(attributes)
  super
  if attributes.include? :messages
    @_cached_messages = Collection.new attributes[:messages]
  end
end

#messages(params = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/fb_graph2/edge/messages.rb', line 11

def messages(params = {})
  messages = if @_cached_messages.present? && params.blank?
    @_cached_messages
  else
    self.edge :messages, params
  end
  messages.collect! do |message|
    Message.new(message[:id], message).authenticate self.access_token
  end
end