lib/sax-machine/sax_document.rb in pauldix-sax-machine-0.0.7 vs lib/sax-machine/sax_document.rb in pauldix-sax-machine-0.0.8

- old
+ new

@@ -33,10 +33,19 @@ end end def elements(name, options = {}) options[:as] ||= name - sax_config.add_collection_element(name, options) + if options[:class] + sax_config.add_collection_element(name, options) + else + class_eval <<-SRC + def add_#{options[:as]}(value) + #{options[:as]} << value + end + SRC + sax_config.add_top_level_element(name, options.merge(:collection => true)) + end class_eval <<-SRC def #{options[:as]} @#{options[:as]} ||= [] end \ No newline at end of file