Class: Manga::Tools::Session

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeSession

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
  @options = {}
end

Instance Attribute Details

#optionsHash

Returns options hash instance.

Returns:

  • (Hash)

    options hash instance



14
15
16
# File 'lib/manga/tools/session.rb', line 14

def options
  @options
end

#storeSessionStore (readonly)

Returns the session store instance.

Returns:



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