Module: ActiveSupport::Messages::SerializerWithFallback::JsonWithFallback

Extended by:
JsonWithFallback
Includes:
ActiveSupport::Messages::SerializerWithFallback
Included in:
JsonWithFallback, JsonWithFallbackAllowMarshal
Defined in:
lib/active_support/messages/serializer_with_fallback.rb

Constant Summary collapse

JSON_START_WITH =
/\A(?:[{\["]|-?\d|true|false|null)/

Instance Method Summary collapse

Methods included from ActiveSupport::Messages::SerializerWithFallback

[], #load

Instance Method Details

#_load(dumped) ⇒ Object



90
91
92
# File 'lib/active_support/messages/serializer_with_fallback.rb', line 90

def _load(dumped)
  ActiveSupport::JSON.decode(dumped)
end

#dump(object) ⇒ Object



86
87
88
# File 'lib/active_support/messages/serializer_with_fallback.rb', line 86

def dump(object)
  ActiveSupport::JSON.encode(object)
end

#dumped?(dumped) ⇒ Boolean

Returns:

  • (Boolean)


96
97
98
# File 'lib/active_support/messages/serializer_with_fallback.rb', line 96

def dumped?(dumped)
  JSON_START_WITH.match?(dumped)
end

#formatObject



82
83
84
# File 'lib/active_support/messages/serializer_with_fallback.rb', line 82

def format
  :json
end