Module: Pacer
- Defined in:
- lib/pacer-orient.rb,
lib/pacer-orient/graph.rb,
lib/pacer-orient/version.rb,
lib/pacer-orient/sql_filter.rb,
lib/pacer-orient/db_listener.rb,
lib/pacer-orient/tx_data_wrapper.rb
Defined Under Namespace
Class Method Summary collapse
-
.orient(url = nil, args = nil) ⇒ Object
Return a graph for the given path.
- .orient_factory(url = nil, args = {}) ⇒ Object
Class Method Details
.orient(url = nil, args = nil) ⇒ Object
Return a graph for the given path. Will create a graph if none exists at that location.
If the graph is opened from a path, it will be registered to be closed by Ruby’s at_exit callback, but if an already open graph is given, it will not.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/pacer-orient.rb', line 55 def orient(url = nil, args = nil) if url.is_a? Pacer::Graph # Don't register the new graph so that it won't be automatically closed. Orient::Graph.new Pacer::Orient::Encoder, proc { url } else open = proc do orient_factory(url, args).get end shutdown = proc do |g| factory = Pacer.open_graphs.delete url factory.shutdown if factory end Orient::Graph.new(Pacer::Orient::Encoder, open, shutdown) end end |
.orient_factory(url = nil, args = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/pacer-orient.rb', line 23 def orient_factory(url = nil, args = {}) if url.nil? url = "memory:#{ next_orient_name }" elsif url.is_a? String and url !~ /^(plocal|local|remote|memory):/ url = "plocal:#{ url }" end if url factory = Pacer.open_graphs[url] if factory factory else if args username = args[:username] password = args[:password] end factory = if username com.tinkerpop.blueprints.impls.orient.OrientGraphFactory.new url, username, password else com.tinkerpop.blueprints.impls.orient.OrientGraphFactory.new url end Pacer::Orient::FactoryContainer.new(factory, url, args) end end end |