Class: Manga::Tools::Session
- Inherits:
-
Object
- Object
- Manga::Tools::Session
- Defined in:
- lib/manga/tools/session.rb
Overview
Network Session class (Session ID handling + HTTP CRUD handling)
Constant Summary collapse
- DEFAULT_HOST =
'https://manga-tools-server.herokuapp.com'
Instance Attribute Summary collapse
-
#options ⇒ Hash
Options hash instance.
-
#store ⇒ SessionStore
readonly
The session store instance.
Instance Method Summary collapse
- #get(path) ⇒ Object
-
#initialize ⇒ Session
constructor
A new instance of Session.
- #post(path, params) ⇒ Object
Constructor Details
#initialize ⇒ Session
Returns a new instance of Session.
19 20 21 22 |
# File 'lib/manga/tools/session.rb', line 19 def initialize @store = Manga::Tools::SessionStore.new = {} end |
Instance Attribute Details
#options ⇒ Hash
Returns options hash instance.
14 15 16 |
# File 'lib/manga/tools/session.rb', line 14 def end |
#store ⇒ SessionStore (readonly)
Returns the session store instance.
17 18 19 |
# File 'lib/manga/tools/session.rb', line 17 def store @store end |
Instance Method Details
#get(path) ⇒ Object
30 31 32 33 |
# File 'lib/manga/tools/session.rb', line 30 def get(path) response = with_session { |session_id| Manga::Tools::Http.get(build_full_url(path), session_id) } JSON.parse(response.body) end |
#post(path, params) ⇒ Object
35 36 37 38 |
# File 'lib/manga/tools/session.rb', line 35 def post(path, params) response = with_session { |session_id| Manga::Tools::Http.post(build_full_url(path), session_id, params) } JSON.parse(response.body) end |