Class: GSGraph::TaggedObject

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

Instance Attribute Summary collapse

Attributes inherited from Node

#access_token, #endpoint, #identifier, #raw_attributes

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
# File 'lib/gs_graph/tagged_object.rb', line 5

def initialize(identifier, attributes = {})
  super
  [: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/gs_graph/tagged_object.rb', line 3

def length
  @length
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#offsetObject

Returns the value of attribute offset.



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

def offset
  @offset
end

Instance Method Details

#fetch_with_class_determinationObject



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

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