@@ -43,25 +43,35 @@ def configure(opts)
43
43
end
44
44
end
45
45
46
- self . indent = opts [ :indent ] if opts . key? ( :indent )
47
- self . space = opts [ :space ] if opts . key? ( :space )
48
- self . space_before = opts [ :space_before ] if opts . key? ( :space_before )
49
- self . array_nl = opts [ :array_nl ] if opts . key? ( :array_nl )
50
- self . object_nl = opts [ :object_nl ] if opts . key? ( :object_nl )
51
- self . max_nesting = opts [ :max_nesting ] || 0 if opts . key? ( :max_nesting )
52
- self . depth = opts [ :depth ] if opts . key? ( :depth )
53
- self . buffer_initial_length = opts [ :buffer_initial_length ] if opts . key? ( :buffer_initial_length )
54
- self . allow_nan = opts [ :allow_nan ] if opts . key? ( :allow_nan )
55
- self . ascii_only = opts [ :ascii_only ] if opts . key? ( :ascii_only )
56
-
57
- if opts . key? ( :script_safe )
58
- self . script_safe = opts [ :script_safe ]
59
- elsif opts . key? ( :escape_slash )
60
- self . script_safe = opts [ :escape_slash ]
46
+ opts . each do |key , value |
47
+ case key
48
+ when :indent
49
+ self . indent = value
50
+ when :space
51
+ self . space = value
52
+ when :space_before
53
+ self . space_before = value
54
+ when :array_nl
55
+ self . array_nl = value
56
+ when :object_nl
57
+ self . object_nl = value
58
+ when :max_nesting
59
+ self . max_nesting = value || 0
60
+ when :depth
61
+ self . depth = value
62
+ when :buffer_initial_length
63
+ self . buffer_initial_length = value
64
+ when :allow_nan
65
+ self . allow_nan = value
66
+ when :ascii_only
67
+ self . ascii_only = value
68
+ when :script_safe , :escape_slash
69
+ self . script_safe = value
70
+ when :strict
71
+ self . strict = value
72
+ end
61
73
end
62
74
63
- self . strict = opts [ :strict ] if opts [ :strict ]
64
-
65
75
self
66
76
end
67
77
0 commit comments