Class: FacebookGraph::GraphNode
- Inherits:
-
Object
- Object
- FacebookGraph::GraphNode
show all
- Includes:
- Helper
- Defined in:
- lib/facebook-graph/base/graph_node.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from HTTPHelper
#get
Constructor Details
#initialize(properties = {}) ⇒ GraphNode
Returns a new instance of GraphNode.
4
5
6
7
|
# File 'lib/facebook-graph/base/graph_node.rb', line 4
def initialize(properties={})
config = FacebookGraph.configuration
@properties = symbolize_keys(properties)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(mname, *args) ⇒ Object
9
10
11
12
13
14
15
16
17
|
# File 'lib/facebook-graph/base/graph_node.rb', line 9
def method_missing(mname, *args)
prop = @properties[mname]
return prop unless prop.nil?
prop = connections_defined? && @properties[:metadata]['connections'][mname.to_s]
super and return unless prop
options = args[0]
prop += "#{querystring_separator(prop) + hash_to_querystring(options)}" if options && options.kind_of?(Hash)
mname == :picture ? prop : FacebookGraph::GraphNode.from_array(parse_json(prop))
end
|
Instance Attribute Details
#properties ⇒ Object
Returns the value of attribute properties.
36
37
38
|
# File 'lib/facebook-graph/base/graph_node.rb', line 36
def properties
@properties
end
|
Class Method Details
.from_array(array) ⇒ Object
32
33
34
|
# File 'lib/facebook-graph/base/graph_node.rb', line 32
def self.from_array(array)
array['data'].map{|el| self.new(el)} if array['data']
end
|
Instance Method Details
#node_id ⇒ Object
24
25
26
|
# File 'lib/facebook-graph/base/graph_node.rb', line 24
def node_id
@properties[:id]
end
|
#respond_to?(mname) ⇒ Boolean
19
20
21
22
|
# File 'lib/facebook-graph/base/graph_node.rb', line 19
def respond_to? mname
is_metadata = connections_defined? && @properties[:metadata]['connections'][mname.to_s]
!!is_metadata || !!@properties[mname] || super(mname)
end
|