Class: Martinet::Session
- Inherits:
-
Object
- Object
- Martinet::Session
- Defined in:
- lib/martinet/session.rb
Overview
HTTP/Warden session-specific behavior.
Instance Method Summary collapse
- #current_user(scope: nil) ⇒ Object
-
#initialize(warden) ⇒ Session
constructor
A new instance of Session.
- #sign_in!(user, *args) ⇒ Object
- #sign_out!(scope: nil) ⇒ Object
- #signed_in?(scope: nil) ⇒ Boolean
Constructor Details
#initialize(warden) ⇒ Session
Returns a new instance of Session.
6 7 8 |
# File 'lib/martinet/session.rb', line 6 def initialize(warden) @warden = warden end |
Instance Method Details
#current_user(scope: nil) ⇒ Object
10 11 12 |
# File 'lib/martinet/session.rb', line 10 def current_user(scope: nil) @warden.user(scope) end |
#sign_in!(user, *args) ⇒ Object
18 19 20 |
# File 'lib/martinet/session.rb', line 18 def sign_in!(user, *args) @warden.set_user(user, *args) end |
#sign_out!(scope: nil) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/martinet/session.rb', line 22 def sign_out!(scope: nil) if scope @warden.logout(scope) else @warden.logout end end |
#signed_in?(scope: nil) ⇒ Boolean
14 15 16 |
# File 'lib/martinet/session.rb', line 14 def signed_in?(scope: nil) @warden.authenticated?(scope) end |