lib/json_builder/compiler.rb in json_builder-3.0.3 vs lib/json_builder/compiler.rb in json_builder-3.0.4

- old
+ new

@@ -6,11 +6,11 @@ class << self def generate(*args, &block) options = args.extract_options! compiler = self.new(options) compiler.compile(*args, &block) - compiler.to_s + compiler.finalize end end attr_accessor :members attr_accessor :array @@ -49,12 +49,16 @@ member = Member.new(key_name, @_scope, *args, &block) @_members << member member end + def finalize + include_callback to_s + end + # Once all nodes are compiled, build the string def to_s - include_callback @_array ? @_array.to_s : "{#{@_members.collect(&:to_s).join(', ')}}" + @_array ? @_array.to_s : "{#{@_members.collect(&:to_s).join(', ')}}" end private def include_callback(json)