lib/global_session/session/v1.rb in global_session-3.2.0 vs lib/global_session/session/v1.rb in global_session-3.2.1
- old
+ new
@@ -55,11 +55,11 @@
# a fresh RSA signature.
#
# === Return
# cookie(String):: Base64Cookie-encoded, Zlib-compressed JSON-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,
@@ -82,9 +82,16 @@
hash['a'] = authority
json = GlobalSession::Encoding::JSON.dump(hash)
zbin = Zlib::Deflate.deflate(json, Zlib::BEST_COMPRESSION)
return GlobalSession::Encoding::Base64Cookie.dump(zbin)
+ 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