From aab503ac51e171be61b98f86196aceffe9cea852 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Waleczek?= Date: Mon, 14 Apr 2014 16:05:18 +0200 Subject: [PATCH] added create_or_fail to relationship indexes --- lib/neography/rest/relationship_indexes.rb | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/neography/rest/relationship_indexes.rb b/lib/neography/rest/relationship_indexes.rb index 8292aa9..8dad382 100644 --- a/lib/neography/rest/relationship_indexes.rb +++ b/lib/neography/rest/relationship_indexes.rb @@ -1,6 +1,6 @@ module Neography class Rest - module RelationshipIndexes + module RelationshipIndexes include Neography::Rest::Helpers def list_relationship_indexes @@ -118,7 +118,21 @@ def get_or_create_unique_relationship(index, key, value, properties = {}) :headers => json_content_type } @connection.post("/index/relationship/%{index}?uniqueness=%{function}" % {:index => index, :function => 'get_or_create'}, options) - + + end + + def create_or_fail_unique_relationship(index, key, value, properties = {}) + options = { + :body => ( + { :properties => properties, + :key => key, + :value => value + } + ).to_json, + :headers => json_content_type + } + @connection.post("/index/relationship/%{index}?uniqueness=%{function}" % {:index => index, :function => 'create_or_fail'}, options) + end end