module Neography::Rest::Helpers

Public Instance Methods

encode(value) click to toggle source
# File lib/neography/rest/helpers.rb, line 35
def encode(value)
  CGI.escape(value.to_s).gsub("+", "%20")
end
escape(value) click to toggle source
# File lib/neography/rest/helpers.rb, line 39
def escape(value)
  if value.class == String
    "%22"+encode(value.to_s)+"%22";
  else
    encode(value.to_s)
  end
end
get_id(id) click to toggle source
# File lib/neography/rest/helpers.rb, line 5
def get_id(id)
  case id
  when Array
    get_id(id.first)
  when Hash
    id["self"].split('/').last
  when String
    id.split('/').last
  when Neography::Node, Neography::Relationship
    id.neo_id
  else
    id
  end
end
json_content_type() click to toggle source
# File lib/neography/rest/helpers.rb, line 20
def json_content_type
  {'Content-Type' => 'application/json'}
end
parse_depth(depth) click to toggle source
# File lib/neography/rest/helpers.rb, line 75
def parse_depth(depth)
  return nil if depth.nil?
  return 1 if depth.to_i == 0
  depth.to_i
end
parse_direction(direction) click to toggle source
# File lib/neography/rest/helpers.rb, line 24
def parse_direction(direction)
  case direction
    when :incoming, "incoming", :in, "in"
      "in"
    when :outgoing, "outgoing", :out, "out"
      "out"
    else
      "all"
  end
end
parse_order(order) click to toggle source
# File lib/neography/rest/helpers.rb, line 47
def parse_order(order)
  case order
    when :breadth, "breadth", "breadth first", "breadthFirst", :wide, "wide"
      "breadth first"
    else
      "depth first"
  end
end
parse_type(type) click to toggle source
# File lib/neography/rest/helpers.rb, line 81
def parse_type(type)
  case type
    when :relationship, "relationship", :relationships, "relationships"
      "relationship"
    when :path, "path", :paths, "paths"
      "path"
    when :fullpath, "fullpath", :fullpaths, "fullpaths"
      "fullpath"
    else
      "node"
  end
end
parse_uniqueness(uniqueness) click to toggle source
# File lib/neography/rest/helpers.rb, line 56
def parse_uniqueness(uniqueness)
  case uniqueness
    when :nodeglobal, "node global", "nodeglobal", "node_global"
      "node global"
    when :nodepath, "node path", "nodepath", "node_path"
      "node path"
    when :noderecent, "node recent", "noderecent", "node_recent"
      "node recent"
    when :relationshipglobal, "relationship global", "relationshipglobal", "relationship_global"
      "relationship global"
    when :relationshippath, "relationship path", "relationshippath", "relationship_path"
      "relationship path"
    when :relationshiprecent, "relationship recent", "relationshiprecent", "relationship_recent"
      "relationship recent"
    else
      "none"
  end
end