Class: FbGraph::Node

Inherits:
Object
  • Object
show all
Includes:
Comparison
Defined in:
lib/fb_graph/node.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Comparison

#==

Constructor Details

#initialize(identifier, options = {}) ⇒ Node

Returns a new instance of Node.



9
10
11
12
13
14
# File 'lib/fb_graph/node.rb', line 9

def initialize(identifier, options = {})
  @identifier         = identifier
  @endpoint           = File.join(ROOT_URL, identifier.to_s)
  @access_token       = options[:access_token]
  @cached_collections = {}
end

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



7
8
9
# File 'lib/fb_graph/node.rb', line 7

def access_token
  @access_token
end

#endpointObject

Returns the value of attribute endpoint.



7
8
9
# File 'lib/fb_graph/node.rb', line 7

def endpoint
  @endpoint
end

#identifierObject

Returns the value of attribute identifier.



7
8
9
# File 'lib/fb_graph/node.rb', line 7

def identifier
  @identifier
end

Class Method Details

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



23
24
25
# File 'lib/fb_graph/node.rb', line 23

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

Instance Method Details

#connection(connection, options = {}) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'lib/fb_graph/node.rb', line 27

def connection(connection, options = {})
  Connection.new(
    self,
    connection,
    options.merge(
      :collection => collection_for(connection, options)
    )
  )
end

#destroy(options = {}) ⇒ Object



41
42
43
# File 'lib/fb_graph/node.rb', line 41

def destroy(options = {})
  delete options
end

#fetch(options = {}) ⇒ Object



16
17
18
19
20
21
# File 'lib/fb_graph/node.rb', line 16

def fetch(options = {})
  options[:access_token] ||= self.access_token if self.access_token
  _fetched_ = get(options)
  _fetched_[:access_token] ||= options[:access_token]
  self.class.new(_fetched_[:id], _fetched_)
end

#update(options = {}) ⇒ Object



37
38
39
# File 'lib/fb_graph/node.rb', line 37

def update(options = {})
  post options
end