Method: PSON::Pure::Parser#initialize
- Defined in:
- lib/puppet/external/pson/pure/parser.rb
#initialize(source, opts = {}) ⇒ Parser
Creates a new PSON::Pure::Parser instance for the string source.
It will be configured by the opts hash. opts can have the following keys:
-
max_nesting: The maximum depth of nesting allowed in the parsed data structures. Disable depth checking with :max_nesting => false|nil|0, it defaults to 19.
-
allow_nan: If set to true, allow NaN, Infinity and -Infinity in defiance of RFC 4627 to be parsed by the Parser. This option defaults to false.
-
object_class: Defaults to Hash
-
array_class: Defaults to Array
65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/puppet/external/pson/pure/parser.rb', line 65 def initialize(source, opts = {}) source = convert_encoding source super source 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 @allow_nan = !!opts[:allow_nan] @object_class = opts[:object_class] || Hash @array_class = opts[:array_class] || Array end |