Module: Authlogic::ActsAsAuthentic::Base::Config

Defined in:
lib/authlogic/acts_as_authentic/base.rb

Instance Method Summary collapse

Instance Method Details

#acts_as_authentic {|_self| ... } ⇒ Object

This includes a lot of helpful methods for authenticating records which The Authlogic::Session module relies on. To use it just do:

class User < ActiveRecord::Base
  acts_as_authentic
end

Configuration is easy:

acts_as_authentic do |c|
  c.my_configuration_option = my_value
end

See the various sub modules for the configuration they provide.

Yields:

  • (_self)

Yield Parameters:



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/authlogic/acts_as_authentic/base.rb', line 26

def acts_as_authentic(&block)
  # Stop all configuration if the DB is not set up
  begin
    column_names
  rescue Exception
    return
  end
  
  yield self if block_given?
  acts_as_authentic_modules.each { |mod| include mod }
end

#add_acts_as_authentic_module(mod) ⇒ Object

Since this part of Authlogic deals with another class, ActiveRecord, we can’t just start including things in ActiveRecord itself. A lot of these module includes need to be triggered by the acts_as_authentic method call. For example, you don’t want to start adding in email validations and what not into a model that has nothing to do with Authlogic.

That being said, this is your tool for extending Authlogic and “hooking” into the acts_as_authentic call.



44
45
46
47
48
49
# File 'lib/authlogic/acts_as_authentic/base.rb', line 44

def add_acts_as_authentic_module(mod)
  modules = acts_as_authentic_modules
  modules << mod
  modules.uniq!
  write_inheritable_attribute(:acts_as_authentic_modules, modules)
end

#remove_acts_as_authentic_module(mod) ⇒ Object

This is the same as add_acts_as_authentic_module, except that it removes the module from the list.



52
53
54
55
# File 'lib/authlogic/acts_as_authentic/base.rb', line 52

def remove_acts_as_authentic_module(mod)
  acts_as_authentic_modules.delete(mod)
  acts_as_authentic_modules
end