123456789_123456789_123456789_123456789_123456789_

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

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, options)
  if options[:value].bytesize > MAX_COOKIE_SIZE
    raise CookieOverflow, "#{name} cookie overflowed with size #{options[:value].bytesize} bytes"
  end
end

#commit(name, options) (private)

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/middleware/cookies.rb', line 608

def commit(name, options)
  options[:value] = serializer.dump(options[:value])
end

#digest (protected)

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/middleware/cookies.rb', line 569

def digest
  request.cookies_digest || "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)

[ GitHub ]

  
# 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.cookies_serializer
    when nil
      ActiveSupport::Messages::SerializerWithFallback[:marshal]
    when :hybrid
      ActiveSupport::Messages::SerializerWithFallback[:json_allow_marshal]
    when Symbol
      ActiveSupport::Messages::SerializerWithFallback[request.cookies_serializer]
    else
      request.cookies_serializer
    end
end