Module: Authlogic::Session::Klass::Config
- Defined in:
- lib/authlogic/session/klass.rb
Instance Method Summary collapse
-
#authenticate_with(klass) ⇒ Object
(also: #authenticate_with=)
Lets you change which model to use for authentication.
-
#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/authlogic/session/klass.rb', line 21 def authenticate_with(klass) @klass_name = klass.name @klass = klass 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/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 43 44 45 |
# File 'lib/authlogic/session/klass.rb', line 40 def klass_name @klass_name ||= if guessed_name = name.scan(/(.*)Session/)[0] @klass_name = guessed_name[0] end end |