Class: Oj::StringWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/oj_serializers/setup.rb

Overview

NOTE: Add an optimization to make it easier to work with a StringWriter transparently in different scenarios.

Instance Method Summary collapse

Instance Method Details

#as_json(_options = nil) ⇒ Object

Internal: ActiveSupport can pass an options argument to ‘as_json` when serializing a Hash or Array.



20
21
22
# File 'lib/oj_serializers/setup.rb', line 20

def as_json(_options = nil)
  original_as_json
end

#original_as_jsonObject



16
# File 'lib/oj_serializers/setup.rb', line 16

alias original_as_json as_json

#to_json(_options = nil) ⇒ Object

Internal: We can use ‘to_s` directly, this is not important but gives a slight boost to a few use cases that use it for caching in Memcached.



26
27
28
# File 'lib/oj_serializers/setup.rb', line 26

def to_json(_options = nil)
  to_s.delete_suffix("\n")
end