Class: GSGraph::Thread::BeforeTransition

Inherits:
Node
  • Object
show all
Defined in:
lib/gs_graph/thread.rb

Overview

NOTE:

Facebook is under transision of their message platform.
This is current thread model in Graph API.
In near future, this will be replaced with GSGraph::Thread model.

Instance Attribute Summary collapse

Attributes inherited from Node

#access_token, #endpoint, #identifier, #raw_attributes

Instance Method Summary collapse

Methods inherited from Node

#connection, #destroy, fetch, #fetch, #update

Methods included from Comparison

#==

Constructor Details

#initialize(identifier, attributes = {}) ⇒ BeforeTransition

Returns a new instance of BeforeTransition.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/gs_graph/thread.rb', line 31

def initialize(identifier, attributes = {})
  super
  @subject = attributes[:subject]
  @message = attributes[:message]
  if (from = attributes[:from])
    @from = if from[:start_time]
      Event.new(from[:id], from)
    else
      User.new(from[:id], from)
    end
  end
  @to = []
  Collection.new(attributes[:to]).each do |to|
    @to << User.new(to[:id], to)
  end
  if attributes[:updated_time]
    @created_time = Time.parse(attributes[:updated_time]).utc
  end
  @unread = attributes[:unread] == 1
  @unseen = attributes[:unseen] == 1

  # cached connection
  cache_collection attributes, :comments
end

Instance Attribute Details

#fromObject

Returns the value of attribute from.



29
30
31
# File 'lib/gs_graph/thread.rb', line 29

def from
  @from
end

#messageObject

Returns the value of attribute message.



29
30
31
# File 'lib/gs_graph/thread.rb', line 29

def message
  @message
end

#subjectObject

Returns the value of attribute subject.



29
30
31
# File 'lib/gs_graph/thread.rb', line 29

def subject
  @subject
end

#toObject

Returns the value of attribute to.



29
30
31
# File 'lib/gs_graph/thread.rb', line 29

def to
  @to
end

#unreadObject

Returns the value of attribute unread.



29
30
31
# File 'lib/gs_graph/thread.rb', line 29

def unread
  @unread
end

#unseenObject

Returns the value of attribute unseen.



29
30
31
# File 'lib/gs_graph/thread.rb', line 29

def unseen
  @unseen
end

#updated_timeObject

Returns the value of attribute updated_time.



29
30
31
# File 'lib/gs_graph/thread.rb', line 29

def updated_time
  @updated_time
end

Instance Method Details

#messages(options = {}) ⇒ Object Also known as: comments

NOTE:

This is a connection named "comments" but returns "messages" and different from normal "comments" connection.
Therefore I put this connection here not under GSGraph::Connections.


59
60
61
62
63
64
65
66
# File 'lib/gs_graph/thread.rb', line 59

def messages(options = {})
  messages = self.connection(:comments, options)
  messages.map! do |message|
    Message.new(message[:id], message.merge(
      :access_token => options[:access_token] || self.access_token
    ))
  end
end