summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorFlorian Frank <flori@ping.de>2011-11-23 13:33:08 +0100
committerFlorian Frank <flori@ping.de>2011-11-23 13:33:08 +0100
commit00cfcd6cee9f22d9b67ebf4ede899392e2f79b3b (patch)
treeafcb87b054b5a174ac47e33a23f9e85d8928f96c /lib
parentf8cb4c25b67a32bbd2c233684e16f514ae7be034 (diff)
parentb1b366d5da6582d3417adc03c1746a2a81b92aa2 (diff)
downloadjson-00cfcd6cee9f22d9b67ebf4ede899392e2f79b3b.tar.gz
Merge branch 'extract-fbuffer'
Diffstat (limited to 'lib')
-rw-r--r--lib/json/pure/generator.rb29
1 files changed, 20 insertions, 9 deletions
diff --git a/lib/json/pure/generator.rb b/lib/json/pure/generator.rb
index 7c9b2ad..9141ae5 100644
--- a/lib/json/pure/generator.rb
+++ b/lib/json/pure/generator.rb
@@ -136,14 +136,15 @@ module JSON
# * *quirks_mode*: Enables quirks_mode for parser, that is for example
# generating single JSON values instead of documents is possible.
def initialize(opts = {})
- @indent = ''
- @space = ''
- @space_before = ''
- @object_nl = ''
- @array_nl = ''
- @allow_nan = false
- @ascii_only = false
- @quirks_mode = false
+ @indent = ''
+ @space = ''
+ @space_before = ''
+ @object_nl = ''
+ @array_nl = ''
+ @allow_nan = false
+ @ascii_only = false
+ @quirks_mode = false
+ @buffer_initial_length = 1024
configure opts
end
@@ -172,6 +173,16 @@ module JSON
# it's disabled.
attr_accessor :quirks_mode
+ # :stopdoc:
+ attr_reader :buffer_initial_length
+
+ def buffer_initial_length=(length)
+ if length > 0
+ @buffer_initial_length = length
+ end
+ end
+ # :startdoc:
+
# This integer returns the current depth data structure nesting in the
# generated JSON.
attr_accessor :depth
@@ -233,7 +244,7 @@ module JSON
# passed to the configure method.
def to_h
result = {}
- for iv in %w[indent space space_before object_nl array_nl allow_nan max_nesting ascii_only quirks_mode depth]
+ for iv in %w[indent space space_before object_nl array_nl allow_nan max_nesting ascii_only quirks_mode buffer_initial_length depth]
result[iv.intern] = instance_variable_get("@#{iv}")
end
result