Skip to content

Commit

Permalink
Add _path suffix in all REST classes.
Browse files Browse the repository at this point in the history
  • Loading branch information
rdvdijk committed Sep 8, 2012
1 parent b8f1312 commit 3b9e97f
Show file tree
Hide file tree
Showing 14 changed files with 67 additions and 67 deletions.
2 changes: 1 addition & 1 deletion lib/neography/rest/batch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Batch
include Neography::Rest::Paths
include Neography::Rest::Helpers

add_path :batch_path, "/batch"
add_path :batch, "/batch"

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


def execute
@connection.delete(clean)
@connection.delete(clean_path)
end

end
Expand Down
16 changes: 8 additions & 8 deletions lib/neography/rest/node_auto_indexes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,45 +15,45 @@ def initialize(connection)
end

def get(key, value)
index = @connection.get(key_value(:key => key, :value => value)) || Array.new
index = @connection.get(key_value_path(:key => key, :value => value)) || Array.new
return nil if index.empty?
index
end

def find(key, value)
@connection.get(key_value(:key => key, :value => value)) || Array.new
@connection.get(key_value_path(:key => key, :value => value)) || Array.new
end

def query(query_expression)
@connection.get(query_index(:query => query_expression)) || Array.new
@connection.get(query_index_path(:query => query_expression)) || Array.new
end

def status
@connection.get(index_status)
@connection.get(index_status_path)
end

def status=(value)
options = {
:body => value.to_json,
:headers => json_content_type
}
@connection.put(index_status, options)
@connection.put(index_status_path, options)
end

def properties
@connection.get(index_properties)
@connection.get(index_properties_path)
end

def add_property(property)
options = {
:body => property,
:headers => json_content_type
}
@connection.post(index_properties, options)
@connection.post(index_properties_path, options)
end

def remove_property(property)
@connection.delete(index_property(:property => property))
@connection.delete(index_property_path(:property => property))
end

end
Expand Down
20 changes: 10 additions & 10 deletions lib/neography/rest/node_indexes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def initialize(connection)
end

def list
@connection.get(all)
@connection.get(all_path)
end

def create(name, type, provider)
Expand All @@ -35,7 +35,7 @@ def create(name, type, provider)
).to_json,
:headers => json_content_type
}
@connection.post(all, options)
@connection.post(all_path, options)
end

def create_auto(type, provider)
Expand All @@ -52,7 +52,7 @@ def create_unique(index, key, value, props)
).to_json,
:headers => json_content_type
}
@connection.post(unique(:index => index), options)
@connection.post(unique_path(:index => index), options)
end

def add(index, key, value, id)
Expand All @@ -65,34 +65,34 @@ def add(index, key, value, id)
).to_json,
:headers => json_content_type
}
@connection.post(base(:index => index), options)
@connection.post(base_path(:index => index), options)
end

def get(index, key, value)
index = @connection.get(key_value(:index => index, :key => key, :value => value)) || Array.new
index = @connection.get(key_value_path(:index => index, :key => key, :value => value)) || Array.new
return nil if index.empty?
index
end

# TODO FIX BUG %20
def find_by_value(index, key, value)
@connection.get(key_value2(:index => index, :key => key, :value => value)) || Array.new
@connection.get(key_value2_path(:index => index, :key => key, :value => value)) || Array.new
end

def find_by_query(index, query)
@connection.get(query(:index => index, :query => query)) || Array.new
@connection.get(query_path(:index => index, :query => query)) || Array.new
end

def remove(index, id)
@connection.delete(node(:index => index, :id => get_id(id)))
@connection.delete(node_path(:index => index, :id => get_id(id)))
end

def remove_by_key(index, id, key)
@connection.delete(key(:index => index, :id => get_id(id), :key => key))
@connection.delete(key_path(:index => index, :id => get_id(id), :key => key))
end

def remove_by_value(index, id, key, value)
@connection.delete(value(:index => index, :id => get_id(id), :key => key, :value => value))
@connection.delete(value_path(:index => index, :id => get_id(id), :key => key, :value => value))
end

end
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 @@ -20,7 +20,7 @@ def get(from, to, relationships, depth, algorithm)
}.to_json,
:headers => json_content_type
}
@connection.post(base(:id => get_id(from)), options) || Hash.new
@connection.post(base_path(:id => get_id(from)), options) || Hash.new
end

def get_all(from, to, relationships, depth, algorithm)
Expand All @@ -32,7 +32,7 @@ def get_all(from, to, relationships, depth, algorithm)
}.to_json,
:headers => json_content_type
}
@connection.post(all(:id => get_id(from)), options) || Array.new
@connection.post(all_path(:id => get_id(from)), options) || Array.new
end

def shortest_weighted(from, to, relationships, weight_attribute, depth, algorithm)
Expand All @@ -45,7 +45,7 @@ def shortest_weighted(from, to, relationships, weight_attribute, depth, algorith
}.to_json,
:headers => json_content_type
}
@connection.post(all(:id => get_id(from)), options) || Hash.new
@connection.post(all_path(:id => get_id(from)), options) || Hash.new
end

private
Expand Down
12 changes: 6 additions & 6 deletions lib/neography/rest/node_properties.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ def initialize(connection)

def reset(id, properties)
options = { :body => properties.to_json, :headers => json_content_type }
@connection.put(all(:id => get_id(id)), options)
@connection.put(all_path(:id => get_id(id)), options)
end

def get(id, *properties)
if properties.none?
@connection.get(all(:id => get_id(id)))
@connection.get(all_path(:id => get_id(id)))
else
get_each(id, *properties)
end
end

def get_each(id, *properties)
node_properties = properties.inject({}) do |memo, property|
value = @connection.get(single(:id => get_id(id), :property => property))
value = @connection.get(single_path(:id => get_id(id), :property => property))
memo[property] = value unless value.nil?
memo
end
Expand All @@ -36,22 +36,22 @@ def get_each(id, *properties)

def remove(id, *properties)
if properties.none?
@connection.delete(all(:id => get_id(id)))
@connection.delete(all_path(:id => get_id(id)))
else
remove_each(id, *properties)
end
end

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

def set(id, properties)
properties.each do |property, value|
options = { :body => value.to_json, :headers => json_content_type }
@connection.put(single(:id => get_id(id), :property => property), options)
@connection.put(single_path(:id => get_id(id), :property => property), options)
end
end

Expand Down
6 changes: 3 additions & 3 deletions lib/neography/rest/node_relationships.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ def create(type, from, to, props)
}.to_json,
:headers => json_content_type }

@connection.post(base(:id => get_id(from)), options)
@connection.post(base_path(:id => get_id(from)), options)
end

def get(id, direction, types)
direction = get_direction(direction)

if types.nil?
node_relationships = @connection.get(direction(:id => get_id(id), :direction => direction)) || Array.new
node_relationships = @connection.get(direction_path(:id => get_id(id), :direction => direction)) || Array.new
else
node_relationships = @connection.get(type(:id => get_id(id), :direction => direction, :types => Array(types).join('&'))) || Array.new
node_relationships = @connection.get(type_path(:id => get_id(id), :direction => direction, :types => Array(types).join('&'))) || Array.new
end
return nil if node_relationships.empty?
node_relationships
Expand Down
2 changes: 1 addition & 1 deletion lib/neography/rest/node_traversal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def traverse(id, return_type, description)

type = get_type(return_type)

@connection.post(traversal(:id => get_id(id), :type => type), options) || Array.new
@connection.post(traversal_path(:id => get_id(id), :type => type), options) || Array.new
end

private
Expand Down
14 changes: 7 additions & 7 deletions lib/neography/rest/nodes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def initialize(connection)
end

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

def get_each(*nodes)
Expand All @@ -25,7 +25,7 @@ def get_each(*nodes)

def root
root_node = @connection.get('/')["reference_node"]
@connection.get("/node/#{get_id(root_node)}")
@connection.get(base_path(:id => get_id(root_node)))
end

def create(*args)
Expand All @@ -41,11 +41,11 @@ def create_with_attributes(attributes)
:body => attributes.delete_if { |k, v| v.nil? }.to_json,
:headers => json_content_type
}
@connection.post(index, options)
@connection.post(index_path, options)
end

def create_empty
@connection.post(index)
@connection.post(index_path)
end

def create_multiple(nodes)
Expand Down Expand Up @@ -73,12 +73,12 @@ def create_multiple_threaded(nodes)
until node_queue.empty? do
node = node_queue.pop
if node.respond_to?(:each_pair)
responses.push( @connection.post(index, {
responses.push( @connection.post(index_path, {
:body => node.to_json,
:headers => json_content_type
} ) )
else
responses.push( @connection.post(index) )
responses.push( @connection.post(index_path) )
end
end
self.join
Expand All @@ -94,7 +94,7 @@ def create_multiple_threaded(nodes)
end

def delete(id)
@connection.delete(base(:id => get_id(id)))
@connection.delete(base_path(:id => get_id(id)))
end

end
Expand Down
16 changes: 8 additions & 8 deletions lib/neography/rest/relationship_auto_indexes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,45 +15,45 @@ def initialize(connection)
end

def get(key, value)
index = @connection.get(key_value(:key => key, :value => value)) || Array.new
index = @connection.get(key_value_path(:key => key, :value => value)) || Array.new
return nil if index.empty?
index
end

def find(key, value)
@connection.get(key_value(:key => key, :value => value)) || Array.new
@connection.get(key_value_path(:key => key, :value => value)) || Array.new
end

def query(query_expression)
@connection.get(query_index(:query => query_expression)) || Array.new
@connection.get(query_index_path(:query => query_expression)) || Array.new
end

def status
@connection.get(index_status)
@connection.get(index_status_path)
end

def status=(value)
options = {
:body => value.to_json,
:headers => json_content_type
}
@connection.put(index_status, options)
@connection.put(index_status_path, options)
end

def properties
@connection.get(index_properties)
@connection.get(index_properties_path)
end

def add_property(property)
options = {
:body => property,
:headers => json_content_type
}
@connection.post(index_properties, options)
@connection.post(index_properties_path, options)
end

def remove_property(property)
@connection.delete(index_property(:property => property))
@connection.delete(index_property_path(:property => property))
end

end
Expand Down
Loading

0 comments on commit 3b9e97f

Please sign in to comment.