lib/simple_auth/session.rb in simple_auth-3.0.0 vs lib/simple_auth/session.rb in simple_auth-3.1.0

- old
+ new

@@ -1,5 +1,7 @@ +# frozen_string_literal: true + module SimpleAuth class Session def self.create(**kwargs) new(**kwargs) end @@ -9,20 +11,17 @@ @session = session self.record = record if record end def record=(record) - @session[record_key] = record.try(:id) + @session[record_key] = record ? record.to_gid.to_s : nil @record = record end def record - @record ||= record_class - .find_by_id(record_id_from_session) if record_id_from_session - end + return unless record_id_from_session - def record_class - @record_class ||= Object.const_get(:"#{@scope.to_s.camelize}") + @record ||= GlobalID::Locator.locate(record_id_from_session) end def record_key :"#{@scope}_id" end