module MultiJson::Adapters::OjCommon
Constants
- OJ_V2
- OJ_V3
- OJ_VERSION
- PRETTY_STATE_PROTOTYPE
Private Instance Methods
prepare_dump_options(options)
click to toggle source
Prepare options for Oj.dump based on Oj version
@api private @param options [Hash] serialization options @return [Hash] processed options for Oj.dump
@example Prepare dump options
prepare_dump_options(pretty: true)
# File lib/multi_json/adapters/oj_common.rb, line 33 def prepare_dump_options(options) if OJ_V2 options[:indent] = 2 if options[:pretty] options[:indent] = options[:indent].to_i if options[:indent] elsif OJ_V3 options.merge!(PRETTY_STATE_PROTOTYPE.dup) if options.delete(:pretty) else raise "Unsupported Oj version: #{::Oj::VERSION}" end options end