lib/scaffold_parser/scaffolders/xsd/parser/handlers/klass.rb in scaffold_parser-0.7.0 vs lib/scaffold_parser/scaffolders/xsd/parser/handlers/klass.rb in scaffold_parser-0.8.0

- old
+ new

@@ -54,14 +54,19 @@ includes.each { |incl| f.puts " include #{incl.full_ref}" } if methods.any? || includes.any? f.puts if methods.any? f.puts methods.map { |method| indent(method.to_s.lines).join }.join("\n\n") f.puts if methods.any? - f.puts " def to_h_with_attrs" - f.puts " hash = ParserCore::HashWithAttributes.new({}, attributes)" + f.puts " def to_h" + f.puts " hash = {}" + f.puts " hash[:attributes] = attributes" f.puts - methods.each { |method| f.puts " #{method.to_h_with_attrs_method}" } + methods.each do |method| + method.to_h_method.lines.each do |line| + f.puts " #{line}" + end + end f.puts if methods.any? if includes.any? f.puts " mega.inject(hash) { |memo, r| memo.merge r }" else f.puts " hash" @@ -94,11 +99,11 @@ f.puts " include ParserCore::BaseBuilder" includes.each { |incl| f.puts " include #{incl.full_ref}" } f.puts f.puts " def builder" f.puts " root = Ox::Element.new(name)" - f.puts " if data.respond_to? :attributes" - f.puts " data.attributes.each { |k, v| root[k] = v }" + f.puts " if data.key? :attributes" + f.puts " data[:attributes].each { |k, v| root[k] = v }" f.puts " end" f.puts if inherit_from f.puts " super.nodes.each do |n|" f.puts " root << n"