# File lib/sax-machine/sax_document.rb, line 55 def ancestor(name, options = {}) real_name = (options[:as] ||= name).to_s sax_config.add_ancestor(name, options) create_attr(real_name) end
# File lib/sax-machine/sax_document.rb, line 43 def attribute(name, options = {}) real_name = (options[:as] ||= name).to_s sax_config.add_top_level_attribute(self.class.to_s, options.merge(:name => name)) create_attr real_name end
# File lib/sax-machine/sax_document.rb, line 65 def column(sym) columns.select { |c| c.column == sym }[0] end
# File lib/sax-machine/sax_document.rb, line 77 def column_names columns.map { |e| e.column } end
# File lib/sax-machine/sax_document.rb, line 61 def columns sax_config.columns end
we only want to insert the getter and setter if they haven’t defined it from elsewhere. this is how we allow custom parsing behavior. So you could define the setter and have it parse the string into a date or whatever.
# File lib/sax-machine/sax_document.rb, line 112 def create_attr real_name attr_reader real_name unless method_defined?(real_name) attr_writer real_name unless method_defined?("#{real_name}=") end
# File lib/sax-machine/sax_document.rb, line 69 def data_class(sym) column(sym).data_class end
# File lib/sax-machine/sax_document.rb, line 37 def element(name, options = {}) real_name = (options[:as] ||= name).to_s sax_config.add_top_level_element(name, options) create_attr real_name end
# File lib/sax-machine/sax_document.rb, line 81 def elements(name, options = {}) options[:as] ||= name if options[:class] sax_config.add_collection_element(name, options) else class_eval def add_#{options[:as]}(value) #{options[:as]} << value end sax_config.add_top_level_element(name, options.merge(:collection => true)) end if !method_defined?(options[:as].to_s) class_eval def #{options[:as]} @#{options[:as]} ||= [] end end attr_writer options[:as] unless method_defined?("#{options[:as]}=") end
# File lib/sax-machine/sax_document.rb, line 29 def inherited(subclass) subclass.sax_config.send(:initialize_copy, self.sax_config) end
# File lib/sax-machine/sax_document.rb, line 33 def parse(xml_text, on_error = nil, on_warning = nil) new.parse(xml_text, on_error, on_warning) end
# File lib/sax-machine/sax_document.rb, line 73 def required?(sym) column(sym).required? end
Generated with the Darkfish Rdoc Generator 2.