Module: Neography::Rest::NodeProperties

Included in:
Neography::Rest
Defined in:
lib/neography/rest/node_properties.rb

Instance Method Summary collapse

Instance Method Details

#get_each_node_properties(id, *properties) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/neography/rest/node_properties.rb', line 25

def get_each_node_properties(id, *properties)
  retrieved_properties = properties.flatten.inject({}) do |memo, property|
    value = @connection.get("/node/%{id}/properties/%{property}" % {:id => get_id(id), :property => property})
    memo[property] = value unless value.nil?
    memo
  end
  return nil if retrieved_properties.empty?
  retrieved_properties
end

#get_node_properties(id, *properties) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/neography/rest/node_properties.rb', line 17

def get_node_properties(id, *properties)
  if properties.none?
    @connection.get("/node/%{id}/properties" % {:id => get_id(id)})
  else
    get_each_node_properties(id, *properties)
  end
end

#remove_each_node_properties(id, *properties) ⇒ Object



43
44
45
46
47
# File 'lib/neography/rest/node_properties.rb', line 43

def remove_each_node_properties(id, *properties)
  properties.flatten.each do |property|
    @connection.delete("/node/%{id}/properties/%{property}" % {:id => get_id(id), :property => property})
  end
end

#remove_node_properties(id, *properties) ⇒ Object



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

def remove_node_properties(id, *properties)
  if properties.none?
    @connection.delete("/node/%{id}/properties" % {:id => get_id(id)})
  else
    remove_each_node_properties(id, *properties)
  end
end

#reset_node_properties(id, properties) ⇒ Object



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

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

#set_node_properties(id, properties) ⇒ Object



5
6
7
8
9
10
# File 'lib/neography/rest/node_properties.rb', line 5

def set_node_properties(id, properties)
  properties.each do |property, value|
    options = { :body => value.to_json, :headers => json_content_type }
    @connection.put("/node/%{id}/properties/%{property}" % {:id => get_id(id), :property => property}, options)
  end
end