Method: PSON.load
- Defined in:
- lib/puppet/external/pson/common.rb
.load(source, proc = nil) ⇒ Object Also known as: restore
Load a ruby data structure from a PSON source and return it. A source can either be a string-like object, an IO like object, or an object responding to the read method. If proc was given, it will be called with any nested Ruby object as an argument recursively in depth first order.
This method is part of the implementation of the load/dump interface of Marshal and YAML.
251 252 253 254 255 256 257 258 259 260 261 262 |
# File 'lib/puppet/external/pson/common.rb', line 251 def load(source, proc = nil) if source.respond_to? :to_str source = source.to_str elsif source.respond_to? :to_io source = source.to_io.read else source = source.read end result = parse(source, :max_nesting => false, :allow_nan => true) recurse_proc(result, &proc) if proc result end |