Method: Jsonify::Builder#initialize

Defined in:
lib/jsonify/builder.rb

#initialize(options = {}) ⇒ Builder

Initializes a new builder. The Jsonify::Builder works by keeping a stack of JsonValues.

Parameters:

  • options (Hash) (defaults to: {})

    the options to create with

Options Hash (options):

  • :verify (boolean)

    Builder will verify that the compiled JSON string is parseable; this option does incur a performance penalty and generally should only be used in development

  • :format (symbol)

    Format for the resultant JSON string; :pretty, the JSON string will be output in a prettier format with new lines and indentation; this option does incur a performance penalty and generally should only be used in development :plain, no formatting (compact one-line JSON – best for production)



38
39
40
41
42
# File 'lib/jsonify/builder.rb', line 38

def initialize(options={})
  @verify = options[:verify].nil? ? false : options[:verify] 
  @pretty = options[:format].to_s == 'pretty' ? true : false 
  reset!
end