Class: Diplomat::Session
- Inherits:
-
RestClient
- Object
- RestClient
- Diplomat::Session
- Defined in:
- lib/diplomat/session.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#create(value) ⇒ String
Create a new session.
-
#destroy(id) ⇒ nil
Destroy a session.
Methods inherited from RestClient
Constructor Details
This class inherits a constructor from Diplomat::RestClient
Class Method Details
.create(*args) ⇒ Object
Note:
This is sugar, see (#create)
29 30 31 |
# File 'lib/diplomat/session.rb', line 29 def self.create *args Diplomat::Session.new.create *args end |
.destroy(*args) ⇒ Object
Note:
This is sugar, see (#destroy)
34 35 36 |
# File 'lib/diplomat/session.rb', line 34 def self.destroy *args Diplomat::Session.new.destroy *args end |
Instance Method Details
#create(value) ⇒ String
Create a new session
9 10 11 12 13 14 15 16 |
# File 'lib/diplomat/session.rb', line 9 def create value raw = @conn.put do |req| req.url "/v1/session/create" req.body = value end body = JSON.parse(raw.body) return body["ID"] end |
#destroy(id) ⇒ nil
Destroy a session
21 22 23 24 25 26 |
# File 'lib/diplomat/session.rb', line 21 def destroy id raw = @conn.put do |req| req.url "/v1/session/destroy/#{id}" end return raw.body end |