summaryrefslogtreecommitdiff
path: root/lib/json/pure/generator.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/json/pure/generator.rb')
-rw-r--r--lib/json/pure/generator.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/json/pure/generator.rb b/lib/json/pure/generator.rb
index fcbc604..76948fb 100644
--- a/lib/json/pure/generator.rb
+++ b/lib/json/pure/generator.rb
@@ -220,6 +220,13 @@ module JSON
# Configure this State instance with the Hash _opts_, and return
# itself.
def configure(opts)
+ if opts.respond_to?(:to_hash)
+ opts = opts.to_hash
+ elsif opts.respond_to?(:to_h)
+ opts = opts.to_h
+ else
+ raise TypeError, "can't convert #{opts.class} into Hash"
+ end
for key, value in opts
instance_variable_set "@#{key}", value
end