Module: Neography::Rest::NodeLabels

Includes:
Helpers
Included in:
Neography::Rest
Defined in:
lib/neography/rest/node_labels.rb

Instance Method Summary collapse

Methods included from Helpers

#encode, #escape, #get_id, #json_content_type, #parse_depth, #parse_direction, #parse_order, #parse_type, #parse_uniqueness

Instance Method Details

#add_label(id, label) ⇒ Object


22
23
24
25
26
27
28
29
30
# File 'lib/neography/rest/node_labels.rb', line 22

def add_label(id, label)
  options = {
    :body => (
      label
    ).to_json,
    :headers => json_content_type
  }
  @connection.post("/node/%{id}/labels"  % {:id => get_id(id)}, options)
end

#delete_label(id, label) ⇒ Object


42
43
44
# File 'lib/neography/rest/node_labels.rb', line 42

def delete_label(id, label)
  @connection.delete("/node/%{id}/labels/%{label}" % {:id => get_id(id), :label => label})
end

#find_nodes_labeled(label, hash) ⇒ Object


18
19
20
# File 'lib/neography/rest/node_labels.rb', line 18

def find_nodes_labeled(label, hash)
  @connection.get("/label/%{label}/nodes?%{property}=%{value}"  % {:label => label, :property => hash.keys.first, :value => escape(hash.values.first)})
end

#get_node_labels(id) ⇒ Object


10
11
12
# File 'lib/neography/rest/node_labels.rb', line 10

def get_node_labels(id)
  @connection.get("/node/%{id}/labels"  % {:id => get_id(id)})
end

#get_nodes_labeled(label) ⇒ Object


14
15
16
# File 'lib/neography/rest/node_labels.rb', line 14

def get_nodes_labeled(label)
  @connection.get("/label/%{label}/nodes" % {:label => label})
end

#list_labelsObject


6
7
8
# File 'lib/neography/rest/node_labels.rb', line 6

def list_labels
  @connection.get("/labels")
end

#set_label(id, label) ⇒ Object


32
33
34
35
36
37
38
39
40
# File 'lib/neography/rest/node_labels.rb', line 32

def set_label(id, label)
  options = {
    :body => (
      Array(label)
    ).to_json,
    :headers => json_content_type
  }
  @connection.put("/node/%{id}/labels"  % {:id => get_id(id)}, options)
end