Module: Neon::Session
- Defined in:
- lib/neon/session.rb,
lib/neon/session/rest.rb,
lib/neon/session/embedded.rb,
lib/neon/session/invalid_session.rb
Overview
A session established with a Neo4J database.
Defined Under Namespace
Classes: Embedded, InvalidSessionTypeError, Rest
Class Attribute Summary collapse
-
.current ⇒ Object
The current default session running right now.
Class Method Summary collapse
-
.class ⇒ Class
The class of the current session.
-
.new(type, *args) ⇒ Session
Create a new session with the database.
-
.running? ⇒ Boolean
Wether the current session is running or not.
-
.start ⇒ Boolean
Starts the current session.
-
.stop ⇒ Boolean
Stops the current session.
Class Attribute Details
.current ⇒ Object
The current default session running right now.
9 10 11 |
# File 'lib/neon/session.rb', line 9 def current @current end |
Class Method Details
.class ⇒ Class
Returns the class of the current session.
32 33 34 |
# File 'lib/neon/session.rb', line 32 def class @current.class end |
.new(type, *args) ⇒ Session
Create a new session with the database.
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/neon/session.rb', line 17 def new(type, *args) session = case type when :rest Rest.new(*args) when :embedded Embedded.new(*args) else raise InvalidSessionTypeError.new(type) end # Set the current session unless one already exists @current = session unless @current session end |
.running? ⇒ Boolean
Returns wether the current session is running or not.
37 38 39 40 41 42 43 |
# File 'lib/neon/session.rb', line 37 def running? if @current @current.running? else false end end |
.start ⇒ Boolean
Starts the current session.
47 48 49 50 51 52 53 |
# File 'lib/neon/session.rb', line 47 def start if @current @current.start else false end end |
.stop ⇒ Boolean
Stops the current session
57 58 59 60 61 62 63 64 65 |
# File 'lib/neon/session.rb', line 57 def stop if @current result = @current.stop @current = nil if result result else true end end |