Skip to content

Commit

Permalink
Merge pull request #61 from rdvdijk/forwarded_rest
Browse files Browse the repository at this point in the history
Use Forwardable in Rest class to delegate API.
  • Loading branch information
maxdemarzi committed Sep 10, 2012
2 parents eb887b0 + c3eaed8 commit b80126e
Show file tree
Hide file tree
Showing 8 changed files with 132 additions and 260 deletions.
370 changes: 121 additions & 249 deletions lib/neography/rest.rb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/neography/rest/cypher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def initialize(connection)
@connection = connection
end

def query(query, parameters)
def query(query, parameters = {})
options = {
:body => {
:query => query,
Expand Down
2 changes: 1 addition & 1 deletion lib/neography/rest/gremlin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def initialize(connection)
@connection = connection
end

def execute(script, parameters)
def execute(script, parameters = {})
options = {
:body => {
:script => script,
Expand Down
4 changes: 2 additions & 2 deletions lib/neography/rest/indexes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def list
@connection.get(all_path)
end

def create(name, type, provider)
def create(name, type = "exact", provider = "lucene")
options = {
:body => (
{ :name => name,
Expand All @@ -27,7 +27,7 @@ def create(name, type, provider)
@connection.post(all_path, options)
end

def create_auto(type, provider)
def create_auto(type = "exact", provider = "lucene")
create("#{@index_type}_auto_index", type, provider)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/neography/rest/node_indexes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def initialize(connection)
super(connection, :node)
end

def create_unique(index, key, value, properties)
def create_unique(index, key, value, properties = {})
options = {
:body => (
{ :properties => properties,
Expand Down
6 changes: 3 additions & 3 deletions lib/neography/rest/node_paths.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ def initialize(connection)
@connection = connection
end

def get(from, to, relationships, depth, algorithm)
def get(from, to, relationships, depth = 1, algorithm = "shortestPath")
options = path_options(to, relationships, depth, algorithm)
@connection.post(base_path(:id => get_id(from)), options) || {}
end

def get_all(from, to, relationships, depth, algorithm)
def get_all(from, to, relationships, depth = 1, algorithm = "allPaths")
options = path_options(to, relationships, depth, algorithm)
@connection.post(all_path(:id => get_id(from)), options) || []
end

def shortest_weighted(from, to, relationships, weight_attribute, depth, algorithm)
def shortest_weighted(from, to, relationships, weight_attribute = "weight", depth = 1, algorithm = "dijkstra")
options = path_options(to, relationships, depth, algorithm, { :cost_property => weight_attribute })
@connection.post(all_path(:id => get_id(from)), options) || {}
end
Expand Down
2 changes: 1 addition & 1 deletion lib/neography/rest/node_relationships.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def initialize(connection)
@connection = connection
end

def create(type, from, to, properties)
def create(type, from, to, properties = nil)
options = {
:body => {
:to => @connection.configuration + "/node/#{get_id(to)}",
Expand Down
4 changes: 2 additions & 2 deletions lib/neography/rest/properties.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def get(id, *properties)
end

def get_each(id, *properties)
retrieved_properties = properties.inject({}) do |memo, property|
retrieved_properties = properties.flatten.inject({}) do |memo, property|
value = @connection.get(single_path(:id => get_id(id), :property => property))
memo[property] = value unless value.nil?
memo
Expand All @@ -46,7 +46,7 @@ def remove(id, *properties)
end

def remove_each(id, *properties)
properties.each do |property|
properties.flatten.each do |property|
@connection.delete(single_path(:id => get_id(id), :property => property))
end
end
Expand Down

0 comments on commit b80126e

Please sign in to comment.