Module: Neography::Rest::RelationshipProperties

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

Instance Method Summary collapse

Instance Method Details

#get_each_relationship_properties(id, *properties) ⇒ Object


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

def get_each_relationship_properties(id, *properties)
  retrieved_properties = properties.flatten.inject({}) do |memo, property|
    value = @connection.get("/relationship/%{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_relationship_properties(id, *properties) ⇒ Object


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

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

#remove_each_relationship_properties(id, *properties) ⇒ Object


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

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

#remove_relationship_properties(id, *properties) ⇒ Object


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

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

#reset_relationship_properties(id, properties) ⇒ Object


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

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

#set_relationship_properties(id, properties) ⇒ Object


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

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