Class: Neography::Rest::NodeLabels

Inherits:
Object
  • Object
show all
Extended by:
Paths
Includes:
Helpers
Defined in:
lib/neography/rest/node_labels.rb

Instance Method Summary collapse

Methods included from Paths

add_path, build_path, encode

Methods included from Helpers

#get_id, #json_content_type, #parse_direction

Constructor Details

#initialize(connection) ⇒ NodeLabels

Returns a new instance of NodeLabels.



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

def initialize(connection)
  @connection = connection
end

Instance Method Details

#add(id, label) ⇒ Object



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

def add(id, label)
  options = {
    :body => (
      label
    ).to_json,
    :headers => json_content_type
  }
  @connection.post(node_path(:id => get_id(id)), options)
end

#delete(id, label) ⇒ Object



53
54
55
# File 'lib/neography/rest/node_labels.rb', line 53

def delete(id, label)
  @connection.delete(delete_path(:id => get_id(id), :label => label))
end

#find_nodes(label, hash) ⇒ Object



29
30
31
# File 'lib/neography/rest/node_labels.rb', line 29

def find_nodes(label, hash)
  @connection.get(find_path(:label => label, :property => hash.keys.first, :value => hash.values.first))
end

#get(id) ⇒ Object



21
22
23
# File 'lib/neography/rest/node_labels.rb', line 21

def get(id)
  @connection.get(node_path(:id => get_id(id)))
end

#get_nodes(label) ⇒ Object



25
26
27
# File 'lib/neography/rest/node_labels.rb', line 25

def get_nodes(label)
  @connection.get(nodes_path(:label => label))
end

#listObject



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

def list
  @connection.get(base_path)
end

#set(id, label) ⇒ Object



43
44
45
46
47
48
49
50
51
# File 'lib/neography/rest/node_labels.rb', line 43

def set(id, label)
  options = {
    :body => (
      Array(label)
    ).to_json,
    :headers => json_content_type
  }
  @connection.put(node_path(:id => get_id(id)), options)
end