Module: CoreExt::ToJsonWithCoreExtEncoder

Defined in:
lib/core_ext/object/json.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#to_json(options = nil) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/core_ext/object/json.rb', line 31

def to_json(options = nil)
  if options.is_a?(::JSON::State)
    # Called from JSON.{generate,dump}, forward it to JSON gem's to_json
    super(options)
  else
    # to_json is being invoked directly, use CoreExt's encoder
    CoreExt::JSON.encode(self, options)
  end
end