Class: DTK::Client::Session
Overview
Session Singleton we will use to hold connection instance, just a singleton wrapper. During shell input it will be needed only once, so singleton was obvious solution.
Instance Attribute Summary collapse
-
#conn ⇒ Object
Returns the value of attribute conn.
Class Method Summary collapse
- .connection_username ⇒ Object
- .get_connection ⇒ Object
- .logout ⇒ Object
-
.post(route, body, opts = {}) ⇒ Object
opts can have key :command_class.
- .re_initialize ⇒ Object
Instance Method Summary collapse
-
#initialize ⇒ Session
constructor
A new instance of Session.
Constructor Details
Instance Attribute Details
#conn ⇒ Object
Returns the value of attribute conn.
281 282 283 |
# File 'lib/core.rb', line 281 def conn @conn end |
Class Method Details
.connection_username ⇒ Object
291 292 293 |
# File 'lib/core.rb', line 291 def self.connection_username Session.instance.conn.get_username end |
.get_connection ⇒ Object
287 288 289 |
# File 'lib/core.rb', line 287 def self.get_connection Session.instance.conn end |
.logout ⇒ Object
301 302 303 304 |
# File 'lib/core.rb', line 301 def self.logout # from this point @conn is not valid, since there are no cookies set Session.instance.conn.logout end |
.post(route, body, opts = {}) ⇒ Object
opts can have key
:command_class
308 309 310 311 312 |
# File 'lib/core.rb', line 308 def self.post(route, body, opts = {}) command_class = opts[:command_class] || Class conn = Session.instance.conn conn.post(command_class, conn.rest_url(route), body) end |