Module: Authlogic::Session::Klass::Config
- Defined in:
- lib/novelys_authlogic/session/klass.rb
Instance Method Summary collapse
-
#authenticate_with(klass) ⇒ Object
(also: #authenticate_with=)
Lets you change which model to use for authentication.
-
#guessed_klass_name ⇒ Object
The string of the model name class guessed from the actual session class name.
-
#klass ⇒ Object
The name of the class that this session is authenticating with.
-
#klass_name ⇒ Object
Same as klass, just returns a string instead of the actual constant.
Instance Method Details
#authenticate_with(klass) ⇒ Object Also known as: authenticate_with=
Lets you change which model to use for authentication.
-
Default:
inferred from the class name. UserSession would automatically try User -
Accepts:
an ActiveRecord class
21 22 23 24 |
# File 'lib/novelys_authlogic/session/klass.rb', line 21 def authenticate_with(klass) @klass_name = klass.name @klass = klass end |
#guessed_klass_name ⇒ Object
The string of the model name class guessed from the actual session class name.
45 46 47 48 |
# File 'lib/novelys_authlogic/session/klass.rb', line 45 def guessed_klass_name guessed_name = name.scan(/(.*)Session/)[0] guessed_name[0] if guessed_name end |
#klass ⇒ Object
The name of the class that this session is authenticating with. For example, the UserSession class will authenticate with the User class unless you specify otherwise in your configuration. See authenticate_with for information on how to change this value.
30 31 32 33 34 35 36 37 |
# File 'lib/novelys_authlogic/session/klass.rb', line 30 def klass @klass ||= if klass_name klass_name.constantize else nil end end |
#klass_name ⇒ Object
Same as klass, just returns a string instead of the actual constant.
40 41 42 |
# File 'lib/novelys_authlogic/session/klass.rb', line 40 def klass_name @klass_name ||= guessed_klass_name end |