Method: JSON::Pure::Generator::State#configure

Defined in:
lib/json/pure/generator.rb

#configure(opts) ⇒ Object Also known as: merge

Configure this State instance with the Hash opts, and return itself.



222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
# File 'lib/json/pure/generator.rb', line 222

def configure(opts)
  @indent         = opts[:indent] if opts.key?(:indent)
  @space          = opts[:space] if opts.key?(:space)
  @space_before   = opts[:space_before] if opts.key?(:space_before)
  @object_nl      = opts[:object_nl] if opts.key?(:object_nl)
  @array_nl       = opts[:array_nl] if opts.key?(:array_nl)
  @allow_nan      = !!opts[:allow_nan] if opts.key?(:allow_nan)
  @ascii_only     = opts[:ascii_only] if opts.key?(:ascii_only)
  @depth          = opts[:depth] || 0
  @quirks_mode    = opts[:quirks_mode] if opts.key?(:quirks_mode)
  if !opts.key?(:max_nesting) # defaults to 19
    @max_nesting = 19
  elsif opts[:max_nesting]
    @max_nesting = opts[:max_nesting]
  else
    @max_nesting = 0
  end
  self
end