Method: JSON::Pure::Generator::State.from_state
- Defined in:
- lib/json/pure/generator.rb
.from_state(opts) ⇒ Object
Creates a State object from opts, which ought to be Hash to create a new State instance configured by opts, something else to create an unconfigured instance. If opts is a State object, it is just returned.
113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/json/pure/generator.rb', line 113 def self.from_state(opts) case when self === opts opts when opts.respond_to?(:to_hash) new(opts.to_hash) when opts.respond_to?(:to_h) new(opts.to_h) else SAFE_STATE_PROTOTYPE.dup end end |