Class: FbGraph2::Node

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from AttributeAssigner

#assign

Constructor Details

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

Returns a new instance of Node.



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

def initialize(id, attributes = {})
  self.id = id
  assign attributes
  authenticate attributes[:access_token] if attributes.include? :access_token
end

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



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

def access_token
  @access_token
end

#idObject Also known as: identifier

Returns the value of attribute id.



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

def id
  @id
end

Instance Method Details

#authenticate(access_token) ⇒ Object



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

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

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



44
45
46
# File 'lib/fb_graph2/node.rb', line 44

def destroy(params = {}, options = {})
  delete params, options
end

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



23
24
25
26
27
28
29
30
31
32
# File 'lib/fb_graph2/node.rb', line 23

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

#edgesObject



34
35
36
37
38
# File 'lib/fb_graph2/node.rb', line 34

def edges
  @edges ||= self.class.included_modules.select do |_module_|
    _module_.name =~ /FbGraph2::Edge/
  end.collect(&:instance_methods).flatten.sort
end

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



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

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

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



40
41
42
# File 'lib/fb_graph2/node.rb', line 40

def update(params = {}, options = {})
  post params, options
end