Module: Authlogic::ActsAsAuthentic::SessionMaintenance::Config

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

Instance Method Summary collapse

Instance Method Details

#maintain_sessions(value = nil) ⇒ Object Also known as: maintain_sessions=

This is more of a convenience method. In order to turn off automatic maintenance of sessions just set this to false, or you can also set the session_ids method to a blank array. Both accomplish the same thing. This method is a little clearer in it's intentions though.

  • Default: true

  • Accepts: Boolean


35
36
37
# File 'lib/authlogic/acts_as_authentic/session_maintenance.rb', line 35

def maintain_sessions(value = nil)
  rw_config(:maintain_sessions, value, true)
end

#session_class(value = nil) ⇒ Object Also known as: session_class=

The name of the associated session class. This is inferred by the name of the model.

  • Default: “#Authlogic::ActsAsAuthentic::SessionMaintenance::Config.klassklass.nameSession”.constantize

  • Accepts: Class


66
67
68
69
70
71
# File 'lib/authlogic/acts_as_authentic/session_maintenance.rb', line 66

def session_class(value = nil)
  namespace = rw_config(:session_class_namespace, nil)

  const = ((namespace.nil? ? "" : "#{namespace}::") + "#{base_class.name}Session").constantize rescue nil
  rw_config(:session_class, value, const)
end

#session_class_namespace(value = nil) ⇒ Object Also known as: session_class_namespace=

In some cases, you can use a different namespace for the session class. If you want to use a model to control access in a namespace and edit it in another namespace, you can define the session class namespace here so authlogic knows where to find it without problems.

  • Default: nil

  • Accepts: Strings


57
58
59
# File 'lib/authlogic/acts_as_authentic/session_maintenance.rb', line 57

def session_class_namespace(value = nil)
  rw_config(:session_class_namespace, value, nil)
end

#session_ids(value = nil) ⇒ Object Also known as: session_ids=

As you may know, authlogic sessions can be separate by id (See Authlogic::Session::Base#id). You can specify here what session ids you want auto maintained. By default it is the main session, which has an id of nil.

  • Default: [nil]

  • Accepts: Array


46
47
48
# File 'lib/authlogic/acts_as_authentic/session_maintenance.rb', line 46

def session_ids(value = nil)
  rw_config(:session_ids, value, [nil])
end