Class: FbGraph::TaggedObject

Inherits:
Node
  • Object
show all
Defined in:
lib/fb_graph/tagged_object.rb

Instance Attribute Summary collapse

Attributes inherited from Node

#access_token, #endpoint, #identifier

Instance Method Summary collapse

Methods inherited from Node

#connection, #destroy, fetch, #fetch, #update

Methods included from Comparison

#==

Constructor Details

#initialize(identifier, attributes = {}) ⇒ TaggedObject

Returns a new instance of TaggedObject.



5
6
7
8
9
10
11
# File 'lib/fb_graph/tagged_object.rb', line 5

def initialize(identifier, attributes = {})
  super
  @raw_attributes = attributes
  [:name, :offset, :length].each do |key|
    self.send("#{key}=", attributes[key])
  end
end

Instance Attribute Details

#lengthObject

Returns the value of attribute length.



3
4
5
# File 'lib/fb_graph/tagged_object.rb', line 3

def length
  @length
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/fb_graph/tagged_object.rb', line 3

def name
  @name
end

#offsetObject

Returns the value of attribute offset.



3
4
5
# File 'lib/fb_graph/tagged_object.rb', line 3

def offset
  @offset
end

#raw_attributesObject

Returns the value of attribute raw_attributes.



3
4
5
# File 'lib/fb_graph/tagged_object.rb', line 3

def raw_attributes
  @raw_attributes
end

Instance Method Details

#fetch_with_class_determinationObject



13
14
15
16
17
18
19
20
21
# File 'lib/fb_graph/tagged_object.rb', line 13

def fetch_with_class_determination
  attributes = fetch_without_class_determination.raw_attributes
  klass = if attributes[:category]
    Page
  else
    User
  end
  klass.new attributes[:id], attributes
end