Class: Neography::Connection
- Inherits:
-
Object
- Object
- Neography::Connection
- Defined in:
- lib/neography/connection.rb
Constant Summary collapse
Instance Attribute Summary collapse
-
#authentication ⇒ Object
Returns the value of attribute authentication.
-
#client ⇒ Object
Returns the value of attribute client.
-
#cypher_path ⇒ Object
Returns the value of attribute cypher_path.
-
#directory ⇒ Object
Returns the value of attribute directory.
-
#gremlin_path ⇒ Object
Returns the value of attribute gremlin_path.
-
#log_enabled ⇒ Object
Returns the value of attribute log_enabled.
-
#log_file ⇒ Object
Returns the value of attribute log_file.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#max_threads ⇒ Object
Returns the value of attribute max_threads.
-
#parser ⇒ Object
Returns the value of attribute parser.
-
#password ⇒ Object
Returns the value of attribute password.
-
#port ⇒ Object
Returns the value of attribute port.
-
#protocol ⇒ Object
Returns the value of attribute protocol.
-
#server ⇒ Object
Returns the value of attribute server.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
- #authenticate(path) ⇒ Object
- #configuration ⇒ Object
- #configure(protocol, server, port, directory) ⇒ Object
- #delete(path, options = {}) ⇒ Object
- #get(path, options = {}) ⇒ Object
-
#initialize(options = ENV['NEO4J_URL'] || {}) ⇒ Connection
constructor
A new instance of Connection.
- #merge_options(options) ⇒ Object
- #post(path, options = {}) ⇒ Object
- #put(path, options = {}) ⇒ Object
Constructor Details
#initialize(options = ENV['NEO4J_URL'] || {}) ⇒ Connection
Returns a new instance of Connection.
12 13 14 15 16 |
# File 'lib/neography/connection.rb', line 12 def initialize( = ENV['NEO4J_URL'] || {}) config = merge_configuration() save_local_configuration(config) @client = HTTPClient.new end |
Instance Attribute Details
#authentication ⇒ Object
Returns the value of attribute authentication.
5 6 7 |
# File 'lib/neography/connection.rb', line 5 def authentication @authentication end |
#client ⇒ Object
Returns the value of attribute client.
5 6 7 |
# File 'lib/neography/connection.rb', line 5 def client @client end |
#cypher_path ⇒ Object
Returns the value of attribute cypher_path.
5 6 7 |
# File 'lib/neography/connection.rb', line 5 def cypher_path @cypher_path end |
#directory ⇒ Object
Returns the value of attribute directory.
5 6 7 |
# File 'lib/neography/connection.rb', line 5 def directory @directory end |
#gremlin_path ⇒ Object
Returns the value of attribute gremlin_path.
5 6 7 |
# File 'lib/neography/connection.rb', line 5 def gremlin_path @gremlin_path end |
#log_enabled ⇒ Object
Returns the value of attribute log_enabled.
5 6 7 |
# File 'lib/neography/connection.rb', line 5 def log_enabled @log_enabled end |
#log_file ⇒ Object
Returns the value of attribute log_file.
5 6 7 |
# File 'lib/neography/connection.rb', line 5 def log_file @log_file end |
#logger ⇒ Object
Returns the value of attribute logger.
5 6 7 |
# File 'lib/neography/connection.rb', line 5 def logger @logger end |
#max_threads ⇒ Object
Returns the value of attribute max_threads.
5 6 7 |
# File 'lib/neography/connection.rb', line 5 def max_threads @max_threads end |
#parser ⇒ Object
Returns the value of attribute parser.
5 6 7 |
# File 'lib/neography/connection.rb', line 5 def parser @parser end |
#password ⇒ Object
Returns the value of attribute password.
5 6 7 |
# File 'lib/neography/connection.rb', line 5 def password @password end |
#port ⇒ Object
Returns the value of attribute port.
5 6 7 |
# File 'lib/neography/connection.rb', line 5 def port @port end |
#protocol ⇒ Object
Returns the value of attribute protocol.
5 6 7 |
# File 'lib/neography/connection.rb', line 5 def protocol @protocol end |
#server ⇒ Object
Returns the value of attribute server.
5 6 7 |
# File 'lib/neography/connection.rb', line 5 def server @server end |
#username ⇒ Object
Returns the value of attribute username.
5 6 7 |
# File 'lib/neography/connection.rb', line 5 def username @username end |
Instance Method Details
#authenticate(path) ⇒ Object
55 56 57 58 59 |
# File 'lib/neography/connection.rb', line 55 def authenticate(path) @client.set_auth(path, @authentication[@authentication.keys.first][:username], @authentication[@authentication.keys.first][:password]) unless @authentication.empty? end |
#configuration ⇒ Object
25 26 27 |
# File 'lib/neography/connection.rb', line 25 def configuration "#{@protocol}#{@server}:#{@port}#{@directory}/db/data" end |
#configure(protocol, server, port, directory) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/neography/connection.rb', line 18 def configure(protocol, server, port, directory) @protocol = protocol @server = server @port = port @directory = directory end |
#delete(path, options = {}) ⇒ Object
50 51 52 53 |
# File 'lib/neography/connection.rb', line 50 def delete(path, ={}) authenticate(configuration + path) evaluate_response(@client.delete(configuration + path, ()[:body], ()[:headers])) end |
#get(path, options = {}) ⇒ Object
35 36 37 38 |
# File 'lib/neography/connection.rb', line 35 def get(path, ={}) authenticate(configuration + path) evaluate_response(@client.get(configuration + path, ()[:body], ()[:headers])) end |
#merge_options(options) ⇒ Object
29 30 31 32 33 |
# File 'lib/neography/connection.rb', line 29 def () = .merge!(@authentication)#.merge!(@parser) [:headers].merge!(@user_agent) if [:headers] end |
#post(path, options = {}) ⇒ Object
40 41 42 43 |
# File 'lib/neography/connection.rb', line 40 def post(path, ={}) authenticate(configuration + path) evaluate_response(@client.post(configuration + path, ()[:body], ()[:headers])) end |
#put(path, options = {}) ⇒ Object
45 46 47 48 |
# File 'lib/neography/connection.rb', line 45 def put(path, ={}) authenticate(configuration + path) evaluate_response(@client.put(configuration + path, ()[:body], ()[:headers])) end |