Class: Neon::Session::Rest

Inherits:
Object
  • Object
show all
Defined in:
lib/neon/session/rest.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url = "http://localhost:7474", auto_tx = false) ⇒ Rest

Returns a new instance of Rest.



9
10
11
12
13
# File 'lib/neon/session/rest.rb', line 9

def initialize(url = "http://localhost:7474", auto_tx = false)
  @neo = Neography::Rest.new url
  @url = url
  @auto_tx = auto_tx
end

Instance Attribute Details

#auto_txObject

Returns the value of attribute auto_tx.



7
8
9
# File 'lib/neon/session/rest.rb', line 7

def auto_tx
  @auto_tx
end

#neoObject (readonly)

Returns the value of attribute neo.



6
7
8
# File 'lib/neon/session/rest.rb', line 6

def neo
  @neo
end

#urlObject (readonly)

Returns the value of attribute url.



6
7
8
# File 'lib/neon/session/rest.rb', line 6

def url
  @url
end

Instance Method Details

#begin_txObject



40
41
42
# File 'lib/neon/session/rest.rb', line 40

def begin_tx
  Transaction::Rest.begin_tx(self)
end

#create_node(attributes, labels) ⇒ Object



23
24
25
26
27
28
# File 'lib/neon/session/rest.rb', line 23

def create_node(attributes, labels)
  node = @neo.create_node(attributes)
  return nil if node.nil?
  @neo.add_label(node, labels)
  Neon::Node::Rest.new(node, self)
end

#load(id) ⇒ Object



30
31
32
33
# File 'lib/neon/session/rest.rb', line 30

def load(id)
  node = @neo.get_node(id)
  Neon::Node::Rest.new(node, self)
end

#load_rel(id) ⇒ Object



35
36
37
38
# File 'lib/neon/session/rest.rb', line 35

def load_rel(id)
  rel = @neo.get_relationship(id)
  Relationship::Rest.new(rel, self)
end

#run_tx(&block) ⇒ Object



44
45
46
# File 'lib/neon/session/rest.rb', line 44

def run_tx(&block)
  Transaction::Placebo.run(begin_tx, &block)
end

#startObject Also known as: stop, running?

These methods make no sense for a rest server so we just return true to make our specs happy



16
17
18
# File 'lib/neon/session/rest.rb', line 16

def start
  true
end

#to_sObject



48
49
50
# File 'lib/neon/session/rest.rb', line 48

def to_s
  @url
end