comparison lib/redmine/views/builders/structure.rb @ 1115:433d4f72a19b redmine-2.2

Update to Redmine SVN revision 11137 on 2.2-stable branch
author Chris Cannam
date Mon, 07 Jan 2013 12:01:42 +0000
parents cbb26bc654de
children 622f24f53b42
comparison
equal deleted inserted replaced
929:5f33065ddc4b 1115:433d4f72a19b
1 # Redmine - project management software 1 # Redmine - project management software
2 # Copyright (C) 2006-2011 Jean-Philippe Lang 2 # Copyright (C) 2006-2012 Jean-Philippe Lang
3 # 3 #
4 # This program is free software; you can redistribute it and/or 4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License 5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2 6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version. 7 # of the License, or (at your option) any later version.
19 19
20 module Redmine 20 module Redmine
21 module Views 21 module Views
22 module Builders 22 module Builders
23 class Structure < BlankSlate 23 class Structure < BlankSlate
24 def initialize 24 attr_accessor :request, :response
25
26 def initialize(request, response)
25 @struct = [{}] 27 @struct = [{}]
28 self.request = request
29 self.response = response
26 end 30 end
27 31
28 def array(tag, options={}, &block) 32 def array(tag, options={}, &block)
29 @struct << [] 33 @struct << []
30 block.call(self) 34 block.call(self)
41 else 45 else
42 @struct.last[sym] = args.first 46 @struct.last[sym] = args.first
43 end 47 end
44 else 48 else
45 if @struct.last.is_a?(Array) 49 if @struct.last.is_a?(Array)
46 @struct.last << (args.last || {}).merge(:value => args.first) 50 if args.size == 1 && !block_given?
51 @struct.last << args.first
52 else
53 @struct.last << (args.last || {}).merge(:value => args.first)
54 end
47 else 55 else
48 @struct.last[sym] = args.first 56 @struct.last[sym] = args.first
49 end 57 end
50 end 58 end
51 end 59 end