lib/global_session/session/v2.rb in global_session-3.2.0 vs lib/global_session/session/v2.rb in global_session-3.2.1

- old
+ new

@@ -56,11 +56,11 @@ # a fresh RSA signature. # # === Return # cookie(String):: Base64Cookie-encoded, Msgpack-serialized global session def to_s - if @cookie && !@dirty_insecure && !@dirty_secure + if @cookie && !dirty? #use cached cookie if nothing has changed return @cookie end hash = {'id' => @id, @@ -86,9 +86,16 @@ hash['a'] = authority array = attribute_hash_to_array(hash) msgpack = GlobalSession::Encoding::Msgpack.dump(array) return GlobalSession::Encoding::Base64Cookie.dump(msgpack) + end + + # Determine whether any state has changed since the session was loaded. + # + # @return [Boolean] true if something has changed + def dirty? + !!(super || @dirty_secure || @dirty_insecure) end # Return the keys that are currently present in the global session. # # === Return