123456789_123456789_123456789_123456789_123456789_

Module: ActiveSupport::Cache::SerializerWithFallback

Do not use. This module is for internal use only.

Constant Summary

Class Method Summary

Instance Method Summary

Class Method Details

.[](format)

[ GitHub ]

  
# File 'activesupport/lib/active_support/cache/serializer_with_fallback.rb', line 9

def self.[](format)
  if format.to_s.include?("message_pack") && !defined?(ActiveSupport::MessagePack)
    require "active_support/message_pack"
  end

  SERIALIZERS.fetch(format)
end

Instance Method Details

#load(dumped)

[ GitHub ]

  
# File 'activesupport/lib/active_support/cache/serializer_with_fallback.rb', line 17

def load(dumped)
  if dumped.is_a?(String)
    case
    when MessagePackWithFallback.dumped?(dumped)
      MessagePackWithFallback._load(dumped)
    when Marshal71WithFallback.dumped?(dumped)
      Marshal71WithFallback._load(dumped)
    when Marshal70WithFallback.dumped?(dumped)
      Marshal70WithFallback._load(dumped)
    else
      Cache::Store.logger&.warn("Unrecognized payload prefix #{dumped.byteslice(0).inspect}; deserializing as nil")
      nil
    end
  elsif PassthroughWithFallback.dumped?(dumped)
    PassthroughWithFallback._load(dumped)
  else
    Cache::Store.logger&.warn("Unrecognized payload class #{dumped.class}; deserializing as nil")
    nil
  end
end

#marshal_load(payload) (private)

[ GitHub ]

  
# File 'activesupport/lib/active_support/cache/serializer_with_fallback.rb', line 39

def marshal_load(payload)
  Marshal.load(payload)
rescue ArgumentError => error
  raise Cache::DeserializationError, error.message
end