Class: Lolita::Extensions::Authentication::DeviseAdapter
- Defined in:
- lib/lolita/extensions/authentication/devise_adapter.rb
Instance Method Summary collapse
- #authenticate_user!(*args) ⇒ Object
- #current_user ⇒ Object
- #edit_path ⇒ Object
-
#initialize(context, options = {}) ⇒ DeviseAdapter
constructor
A new instance of DeviseAdapter.
- #sign_out_path ⇒ Object
- #sign_out_via ⇒ Object
- #user_signed_in? ⇒ Boolean
Constructor Details
#initialize(context, options = {}) ⇒ DeviseAdapter
Returns a new instance of DeviseAdapter.
6 7 8 9 |
# File 'lib/lolita/extensions/authentication/devise_adapter.rb', line 6 def initialize context, ={} raise Lolita::NoAuthenticationDefinedError, "Lolita.authentication is not defined" unless Lolita.authentication @context = context end |
Instance Method Details
#authenticate_user!(*args) ⇒ Object
24 25 26 |
# File 'lib/lolita/extensions/authentication/devise_adapter.rb', line 24 def authenticate_user! *args @context.send(Lolita.authentication) end |
#current_user ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/lolita/extensions/authentication/devise_adapter.rb', line 11 def current_user unless @current_user find_class_and_user do |klass,user| @current_user = user end end @current_user end |
#edit_path ⇒ Object
32 33 34 35 36 |
# File 'lib/lolita/extensions/authentication/devise_adapter.rb', line 32 def edit_path find_class_and_user do |klass,user| return @context.send(:"edit_#{klass.to_s.downcase}_password_path") end end |
#sign_out_path ⇒ Object
38 39 40 41 42 |
# File 'lib/lolita/extensions/authentication/devise_adapter.rb', line 38 def sign_out_path find_class_and_user do |klass,user| return @context.send(:"destroy_#{klass.to_s.downcase}_session_path") end end |
#sign_out_via ⇒ Object
28 29 30 |
# File 'lib/lolita/extensions/authentication/devise_adapter.rb', line 28 def sign_out_via ::Devise.sign_out_via end |
#user_signed_in? ⇒ Boolean
20 21 22 |
# File 'lib/lolita/extensions/authentication/devise_adapter.rb', line 20 def user_signed_in? !!current_user end |