Module: Neography::Rest::Helpers
- Included in:
- Neography::Rest, Batch, Clean, Constraints, Cypher, Extensions, Gremlin, NodeIndexes, NodeLabels, NodePaths, NodeRelationships, NodeTraversal, Nodes, OtherNodeRelationships, RelationshipIndexes, Relationships, SchemaIndexes, Spatial, Transactions
- Defined in:
- lib/neography/rest/helpers.rb
Instance Method Summary collapse
- #encode(value) ⇒ Object
- #escape(value) ⇒ Object
- #get_id(id) ⇒ Object
- #json_content_type ⇒ Object
- #parse_depth(depth) ⇒ Object
- #parse_direction(direction) ⇒ Object
- #parse_order(order) ⇒ Object
- #parse_type(type) ⇒ Object
- #parse_uniqueness(uniqueness) ⇒ Object
Instance Method Details
#encode(value) ⇒ Object
35 36 37 |
# File 'lib/neography/rest/helpers.rb', line 35 def encode(value) CGI.escape(value.to_s).gsub("+", "%20") end |
#escape(value) ⇒ Object
39 40 41 42 43 44 45 |
# 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) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# 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 ⇒ Object
20 21 22 |
# File 'lib/neography/rest/helpers.rb', line 20 def json_content_type {'Content-Type' => 'application/json'} end |
#parse_depth(depth) ⇒ Object
75 76 77 78 79 |
# 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) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# 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) ⇒ Object
47 48 49 50 51 52 53 54 |
# 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) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 |
# 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) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# 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 |