Class: Hello::RequestManager::Stateful
- Defined in:
- lib/hello/request_manager/stateful.rb,
lib/hello/request_manager/stateful/finder.rb,
lib/hello/request_manager/stateful/session_wrapper.rb
Defined Under Namespace
Classes: Finder, SessionWrapper
Instance Method Summary collapse
- #current_access ⇒ Object
-
#initialize(*args) ⇒ Stateful
constructor
A new instance of Stateful.
-
#sign_in!(*args) ⇒ Object
write.
-
#sign_out!(access = current_access) ⇒ Object
delete.
- #stateful? ⇒ Boolean
Methods inherited from Abstract
#clear_cache, #current_accesses, #current_user, #env, #is_current_access?, #is_current_user?, #remote_ip, #request, #signed_in?, #user_agent
Constructor Details
#initialize(*args) ⇒ Stateful
Returns a new instance of Stateful.
8 9 10 11 12 |
# File 'lib/hello/request_manager/stateful.rb', line 8 def initialize(*args) super(*args) @finder = Finder.new(self) @session_wrapper = SessionWrapper.new(self) end |
Instance Method Details
#current_access ⇒ Object
27 28 29 30 31 |
# File 'lib/hello/request_manager/stateful.rb', line 27 def current_access if session_token.presence @current_access ||= current_accesses.find { |a| a.token == session_token } end end |
#sign_in!(*args) ⇒ Object
write
35 36 37 38 39 40 |
# File 'lib/hello/request_manager/stateful.rb', line 35 def sign_in!(*args) super(*args).tap do |access| self.session_token = access.token session_tokens << access.token end end |
#sign_out!(access = current_access) ⇒ Object
delete
44 45 46 47 48 49 50 |
# File 'lib/hello/request_manager/stateful.rb', line 44 def sign_out!(access = current_access) self.session_token = session_tokens.first if is_current_access?(access) super(access) refresh_session_tokens end |
#stateful? ⇒ Boolean
19 20 21 |
# File 'lib/hello/request_manager/stateful.rb', line 19 def stateful? true end |