SAXMachine::ClassMethods

Public Instance Methods

column(sym) click to toggle source
# File lib/sax-machine/sax_document.rb, line 37
def column(sym)
  columns.select{|c| c.column == sym}[0]
end
column_names() click to toggle source
# File lib/sax-machine/sax_document.rb, line 49
def column_names
  columns.map{|e| e.column}
end
columns() click to toggle source
# File lib/sax-machine/sax_document.rb, line 33
def columns
  sax_config.columns
end
data_class(sym) click to toggle source
# File lib/sax-machine/sax_document.rb, line 41
def data_class(sym)
  column(sym).data_class
end
element(name, options = {}) click to toggle source
# File lib/sax-machine/sax_document.rb, line 22
def element(name, options = {})
  options[:as] ||= name
  sax_config.add_top_level_element(name, options)
  
  # 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.
  attr_reader options[:as] unless instance_methods.include?(options[:as].to_s)
  attr_writer options[:as] unless instance_methods.include?("#{options[:as]}=")
end
elements(name, options = {}) click to toggle source
# File lib/sax-machine/sax_document.rb, line 53
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 !instance_methods.include?(options[:as].to_s)
  class_eval           def #{options[:as]}            @#{options[:as]} ||= []          end
  end
  
  attr_writer options[:as] unless instance_methods.include?("#{options[:as]}=")
end
parse(xml_text) click to toggle source
# File lib/sax-machine/sax_document.rb, line 18
def parse(xml_text)
  new.parse(xml_text)
end
required?(sym) click to toggle source
# File lib/sax-machine/sax_document.rb, line 45
def required?(sym)
  column(sym).required?
end
sax_config() click to toggle source
# File lib/sax-machine/sax_document.rb, line 77
def sax_config
  @sax_config ||= SAXConfig.new
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.