Class: AllegroGraph::Session
- Defined in:
- lib/allegro_graph/session.rb
Overview
The Session class wrap the corresponding resource on the AllegroGraph server.
Instance Attribute Summary collapse
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Attributes inherited from Resource
#geometric, #mapping, #query, #statements
Class Method Summary collapse
Instance Method Summary collapse
- #commit ⇒ Object
-
#initialize(options = { }) ⇒ Session
constructor
A new instance of Session.
- #path ⇒ Object
- #request_http(http_method, path, options = { }) ⇒ Object
- #request_json(http_method, path, options = { }) ⇒ Object
- #rollback ⇒ Object
Constructor Details
#initialize(options = { }) ⇒ Session
Returns a new instance of Session.
11 12 13 14 15 16 |
# File 'lib/allegro_graph/session.rb', line 11 def initialize( = { }) super @url = [:url] @username = [:username] @password = [:password] end |
Instance Attribute Details
#password ⇒ Object (readonly)
Returns the value of attribute password.
9 10 11 |
# File 'lib/allegro_graph/session.rb', line 9 def password @password end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
7 8 9 |
# File 'lib/allegro_graph/session.rb', line 7 def url @url end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
8 9 10 |
# File 'lib/allegro_graph/session.rb', line 8 def username @username end |
Class Method Details
.create(repository) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/allegro_graph/session.rb', line 40 def self.create(repository) response = repository.request_http :post, repository.path + "/session", :expected_status_code => 200 url = response.sub(/^"/, "").sub(/"$/, "") server = repository.server new :url => url, :username => server.username, :password => server.password end |
Instance Method Details
#commit ⇒ Object
30 31 32 33 |
# File 'lib/allegro_graph/session.rb', line 30 def commit self.request_http :post, "/commit", :expected_status_code => 204 true end |
#path ⇒ Object
18 19 20 |
# File 'lib/allegro_graph/session.rb', line 18 def path "" end |
#request_http(http_method, path, options = { }) ⇒ Object
22 23 24 |
# File 'lib/allegro_graph/session.rb', line 22 def request_http(http_method, path, = { }) ::Transport::HTTP.request http_method, self.url + path, credentials.merge() end |
#request_json(http_method, path, options = { }) ⇒ Object
26 27 28 |
# File 'lib/allegro_graph/session.rb', line 26 def request_json(http_method, path, = { }) ::Transport::JSON.request http_method, self.url + path, credentials.merge() end |
#rollback ⇒ Object
35 36 37 38 |
# File 'lib/allegro_graph/session.rb', line 35 def rollback self.request_http :post, "/rollback", :expected_status_code => 204 true end |