Module: Authlogic::Session::PriorityRecord
- Included in:
- Base
- Defined in:
- lib/authlogic/session/priority_record.rb
Overview
The point of this module is to avoid the StaleObjectError raised when lock_version is implemented in ActiveRecord. We accomplish this by using a “priority record”. Meaning this record is used if possible, it gets priority. This way we don’t save a record behind the scenes thus making an object being used stale.
Class Method Summary collapse
Instance Method Summary collapse
-
#credentials=(value) ⇒ Object
Setting priority record if it is passed.
Class Method Details
.included(klass) ⇒ Object
7 8 9 10 11 |
# File 'lib/authlogic/session/priority_record.rb', line 7 def self.included(klass) klass.class_eval do attr_accessor :priority_record end end |
Instance Method Details
#credentials=(value) ⇒ Object
Setting priority record if it is passed. The only way it can be passed is through an array:
session.credentials = [real_user_object, priority_user_object]
16 17 18 19 20 |
# File 'lib/authlogic/session/priority_record.rb', line 16 def credentials=(value) super values = value.is_a?(Array) ? value : [value] self.priority_record = values[1] if values[1].class < ::ActiveRecord::Base end |