Module: Related::Helpers

Included in:
Related
Defined in:
lib/related/helpers.rb

Instance Method Summary collapse

Instance Method Details

#generate_idObject

Generate a unique id



8
9
10
11
12
# File 'lib/related/helpers.rb', line 8

def generate_id
  Base64.encode64(
    Digest::MD5.digest("#{Time.now}-#{rand}")
  ).gsub('/','x').gsub('+','y').gsub('=','').strip
end

#rootObject

Returns the root node for the graph



15
16
17
# File 'lib/related/helpers.rb', line 15

def root
  @root ||= Related::Root.new
end