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