Class: GSGraph::OpenGraph::Action

Inherits:
Node
  • Object
show all
Includes:
Connections::Comments, Connections::Likes, Connections::Likes::Likable
Defined in:
lib/gs_graph/open_graph/action.rb

Instance Attribute Summary collapse

Attributes inherited from Node

#access_token, #endpoint, #identifier

Instance Method Summary collapse

Methods included from Connections::Likes::Likable

#like!, #unlike!

Methods included from Connections::Likes

#likes

Methods included from Connections::Comments

#comment!, #comments

Methods inherited from Node

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

Methods included from Comparison

#==

Constructor Details

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

Returns a new instance of Action.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/gs_graph/open_graph/action.rb', line 11

def initialize(identifier, attributes = {})
  super
  @raw_attributes = attributes
  @type = attributes[:type]
  if application = attributes[:application]
    @application = Application.new(application[:id], application)
  end
  if from = attributes[:from]
    @from = User.new(from[:id], from)
  end
  @objects = {}
  if attributes[:data]
    attributes[:data].each do |key, _attributes_|
      @objects[key] = case _attributes_
      when Hash
        Object.new _attributes_[:id], _attributes_
      else
        _attributes_
      end
    end
  end
  @objects = @objects.with_indifferent_access
  [:start_time, :end_time, :publish_time].each do |key|
    self.send "#{key}=", Time.parse(attributes[key]) if attributes[key]
  end

  # cached connection
  cache_collections attributes, :comments, :likes
end

Instance Attribute Details

#applicationObject

Returns the value of attribute application.



8
9
10
# File 'lib/gs_graph/open_graph/action.rb', line 8

def application
  @application
end

#end_timeObject

Returns the value of attribute end_time.



8
9
10
# File 'lib/gs_graph/open_graph/action.rb', line 8

def end_time
  @end_time
end

#fromObject

Returns the value of attribute from.



8
9
10
# File 'lib/gs_graph/open_graph/action.rb', line 8

def from
  @from
end

#objectsObject

Returns the value of attribute objects.



8
9
10
# File 'lib/gs_graph/open_graph/action.rb', line 8

def objects
  @objects
end

#publish_timeObject

Returns the value of attribute publish_time.



8
9
10
# File 'lib/gs_graph/open_graph/action.rb', line 8

def publish_time
  @publish_time
end

#raw_attributesObject

Returns the value of attribute raw_attributes.



9
10
11
# File 'lib/gs_graph/open_graph/action.rb', line 9

def raw_attributes
  @raw_attributes
end

#start_timeObject

Returns the value of attribute start_time.



8
9
10
# File 'lib/gs_graph/open_graph/action.rb', line 8

def start_time
  @start_time
end

#typeObject

Returns the value of attribute type.



8
9
10
# File 'lib/gs_graph/open_graph/action.rb', line 8

def type
  @type
end