lib/authlogic/session/foundation.rb in Empact-authlogic-2.1.5 vs lib/authlogic/session/foundation.rb in Empact-authlogic-3.0.3
- old
+ new
@@ -4,23 +4,29 @@
# other modules to overwrite methods and call super on them. It's also a place to put "utility" methods used
# throughout Authlogic.
module Foundation
def self.included(klass)
klass.class_eval do
+ class_attribute :acts_as_authentic_config
+ self.acts_as_authentic_config ||= {}
+
extend ClassMethods
include InstanceMethods
end
end
module ClassMethods
private
def rw_config(key, value, default_value = nil, read_value = nil)
if value == read_value
- return read_inheritable_attribute(key) if inheritable_attributes.include?(key)
- write_inheritable_attribute(key, default_value)
+ return acts_as_authentic_config[key] if acts_as_authentic_config.include?(key)
+ rw_config(key, default_value)
else
- write_inheritable_attribute(key, value)
+ config = acts_as_authentic_config.clone
+ config[key] = value
+ self.acts_as_authentic_config = config
+ value
end
end
end
module InstanceMethods
@@ -49,9 +55,17 @@
def credentials=(values)
end
def inspect
"#<#{self.class.name}: #{credentials.blank? ? "no credentials provided" : credentials.inspect}>"
+ end
+
+ def persisted?
+ !(new_record? || destroyed?)
+ end
+
+ def to_key
+ new_record? ? nil : [ self.send(self.class.primary_key) ]
end
private
def build_key(last_part)
last_part
\ No newline at end of file