Class: FbGraph2::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/fb_graph2/node.rb

Direct Known Subclasses

Achievement, Album, Application, Event, FriendList, Group, Page, Post, User

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, attributes = {}) ⇒ Node

Returns a new instance of Node.



9
10
11
12
# File 'lib/fb_graph2/node.rb', line 9

def initialize(id, attributes = {})
  self.id = id
  assign attributes if respond_to?(:assign)
end

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



3
4
5
# File 'lib/fb_graph2/node.rb', line 3

def access_token
  @access_token
end

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/fb_graph2/node.rb', line 3

def id
  @id
end

#raw_attributesObject

Returns the value of attribute raw_attributes.



3
4
5
# File 'lib/fb_graph2/node.rb', line 3

def raw_attributes
  @raw_attributes
end

Class Method Details

.fetch(identifier, params = {}) ⇒ Object



24
25
26
# File 'lib/fb_graph2/node.rb', line 24

def self.fetch(identifier, params = {})
  new(identifier).fetch params
end

.inherited(klass) ⇒ Object



5
6
7
# File 'lib/fb_graph2/node.rb', line 5

def self.inherited(klass)
  klass.include AttributeAssigner
end

Instance Method Details

#authenticate(access_token) ⇒ Object



14
15
16
17
# File 'lib/fb_graph2/node.rb', line 14

def authenticate(access_token)
  self.access_token = access_token
  self
end

#edge(edge, params = {}, options = {}) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/fb_graph2/node.rb', line 28

def edge(edge, params = {}, options = {})
  Edge.new(
    self,
    edge,
    params,
    options.merge(
      collection: edge_for(edge, params, options)
    )
  )
end

#fetch(params = {}) ⇒ Object



19
20
21
22
# File 'lib/fb_graph2/node.rb', line 19

def fetch(params = {})
  attributes = get params
  self.class.new(attributes[:id], attributes).authenticate access_token
end