Class: Lolita::Extensions::Authentication::DeviseAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/lolita/extensions/authentication/devise_adapter.rb

Instance Method Summary collapse

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, options={}
  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_userObject



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_pathObject



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_pathObject



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_viaObject



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

Returns:

  • (Boolean)


20
21
22
# File 'lib/lolita/extensions/authentication/devise_adapter.rb', line 20

def user_signed_in?
  !!current_user
end