Module: ActionDispatch::Cookies::SerializedCookieJars
Do not use. This module is for internal use only.
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Included In:
| |
Defined in: | actionpack/lib/action_dispatch/middleware/cookies.rb |
Constant Summary
Instance Method Summary
- #digest protected
- #check_for_overflow!(name, options) private
- #commit(name, options) private
- #parse(name, dumped, force_reserialize: false) private
- #reserialize?(dumped) ⇒ Boolean private
- #serializer private
Instance Method Details
#check_for_overflow!(name, options) (private)
[ GitHub ]# File 'actionpack/lib/action_dispatch/middleware/cookies.rb', line 612
def check_for_overflow!(name, ) if [:value].bytesize > MAX_COOKIE_SIZE raise CookieOverflow, "#{name} cookie overflowed with size #{ [:value].bytesize} bytes" end end
#commit(name, options) (private)
[ GitHub ]# File 'actionpack/lib/action_dispatch/middleware/cookies.rb', line 608
def commit(name, ) [:value] = serializer.dump( [:value]) end
#digest (protected)
[ GitHub ]# File 'actionpack/lib/action_dispatch/middleware/cookies.rb', line 569
def digest request. || "SHA1" end
#parse(name, dumped, force_reserialize: false) (private)
[ GitHub ]# File 'actionpack/lib/action_dispatch/middleware/cookies.rb', line 594
def parse(name, dumped, force_reserialize: false, **) if dumped begin value = serializer.load(dumped) rescue StandardError return end self[name] = { value: value } if force_reserialize || reserialize?(dumped) value end end
#reserialize?(dumped) ⇒ Boolean
(private)
# File 'actionpack/lib/action_dispatch/middleware/cookies.rb', line 588
def reserialize?(dumped) serializer.is_a?(ActiveSupport::Messages::SerializerWithFallback) && serializer != ActiveSupport::Messages::SerializerWithFallback[:marshal] && !serializer.dumped?(dumped) end
#serializer (private)
[ GitHub ]# File 'actionpack/lib/action_dispatch/middleware/cookies.rb', line 574
def serializer @serializer ||= case request. when nil ActiveSupport::Messages::SerializerWithFallback[:marshal] when :hybrid ActiveSupport::Messages::SerializerWithFallback[:json_allow_marshal] when Symbol ActiveSupport::Messages::SerializerWithFallback[request. ] else request. end end