summaryrefslogtreecommitdiff
path: root/lib/json
diff options
context:
space:
mode:
Diffstat (limited to 'lib/json')
-rw-r--r--lib/json/pure/generator.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/json/pure/generator.rb b/lib/json/pure/generator.rb
index 335c6ae..94cb239 100644
--- a/lib/json/pure/generator.rb
+++ b/lib/json/pure/generator.rb
@@ -106,11 +106,13 @@ module JSON
# an unconfigured instance. If _opts_ is a State object, it is just
# returned.
def self.from_state(opts)
- case opts
- when self
+ case
+ when self === opts
opts
- when Hash
- new(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