Skip to Content Skip to Search
Methods
D
L

Constants

MARSHAL_SIGNATURE = "\x04\x08"
 

Class Public methods

dump(value)

# File activesupport/lib/active_support/json_with_marshal_fallback.rb, line 19
def dump(value)
  if self.use_marshal_serialization
    Marshal.dump(value)
  else
    JSON.encode(value)
  end
end

load(value)

# File activesupport/lib/active_support/json_with_marshal_fallback.rb, line 27
def load(value)
  if self.fallback_to_marshal_deserialization
    if value.start_with?(MARSHAL_SIGNATURE)
      logger.warn("JsonWithMarshalFallback: Marshal load fallback occurred.") if logger
      Marshal.load(value)
    else
      JSON.decode(value)
    end
  else
    raise ::JSON::ParserError if value.start_with?(MARSHAL_SIGNATURE)
    JSON.decode(value)
  end
end

logger()

# File activesupport/lib/active_support/json_with_marshal_fallback.rb, line 11
def logger
  if defined?(Rails) && Rails.respond_to?(:logger)
    Rails.logger
  else
    nil
  end
end