lib/n4j/request.rb in n4j-0.0.1.5 vs lib/n4j/request.rb in n4j-0.0.1.6
- old
+ new
@@ -3,16 +3,31 @@
module N4j::Request
extend ActiveSupport::Concern
included do
end
module ClassMethods
+
+ def destroy_everything!
+ clean_path = N4j.neo4j_url_prefix.sub('/db/data','/cleandb/all-gone')
+ RestClient.delete(clean_path)
+ end
+
def neo4j_url_prefix
- @neo4j_url_prefix ||= "http://localhost:#{port}/db/data"
+ @neo4j_url_prefix ||= if ENV['NEO4J_REST_URL']
+ "#{ENV['NEO4J_REST_URL']}/"
+ else
+ "http://#{host}:#{port}/db/data"
+ end
end
def port
config = YAML.load_file("config/n4j.yml")
config[Rails.env]['port']
+ end
+
+ def host
+ config = YAML.load_file("config/n4j.yml")
+ config[Rails.env]['host'] || 'localhost'
end
def neo4j_hash?(hsh)
hsh && hsh['self'] && hsh['property'] && hsh['properties']
end