lib/graph/vertex.rb in graph-rb-0.1.0 vs lib/graph/vertex.rb in graph-rb-0.1.1

- old
+ new

@@ -1,13 +1,17 @@ class Graph::Vertex + attr_reader :key, :graph attr_accessor :attachment - attr_reader :uid, :graph + @@autoincrement_counter = 0 - def initialize(attachment = nil) - uid = @@autoincrement_counter += 1 - @uid = uid + def initialize(key: nil, attachment: nil) + @key = key || (@@autoincrement_counter += 1) @attachment = attachment + end + + def to_h + { edges: [], attachment: attachment.to_h } end private def add_to(graph)