Class: FbGraph2::Node

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Node.



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

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



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

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

.inherited(klass) ⇒ Object



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

def self.inherited(klass)
  klass.include AttributeAssigner
  FbGraph2.object_classes << klass
end

Instance Method Details

#authenticate(access_token) ⇒ Object



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

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

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



50
51
52
# File 'lib/fb_graph2/node.rb', line 50

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

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



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

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

#edgesObject



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

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

#fetch(params = {}) ⇒ Object



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

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

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



46
47
48
# File 'lib/fb_graph2/node.rb', line 46

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