Sha256: ed73958a0f181e113817c66dd70b2d491ce1413e4238350a8a2ad1c426f5231a

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

class Quickbooks::DtdParser < Quickbooks::QbxmlParser
  include Quickbooks::Support::ClassBuilder

def parse_file(qbxml_file)
  parse( 
    cleanup_qbxml(
      File.read(qbxml_file)))
end

private

def process_leaf_node(xml_obj, parent_class)
 attr_name, qb_type = parse_leaf_node_data(xml_obj)
  if parent_class
    add_casting_attribute(parent_class, attr_name, qb_type)
  end
end

def process_non_leaf_node(xml_obj, parent_class)
  klass = build_qbxml_class(xml_obj)
  attr_name = to_attribute_name(xml_obj)
  if parent_class
    add_strict_attribute(parent_class, attr_name, klass)
  end
  klass
end

def process_comment_node(xml_obj, parent_class)
  parent_class
end

# helpers

def build_qbxml_class(xml_obj)
  obj_name = xml_obj.name
  unless qbxml_class_defined?(obj_name) 
    klass = Class.new(QbxmlBase)
    get_schema_namespace.const_set(obj_name, klass) 
    xml_obj = set_required_attributes(xml_obj)
    add_xml_template(klass, xml_obj.to_xml)
  else
    klass = get_schema_namespace.const_get(obj_name)
  end
  klass
end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
quickbooks_api-0.0.7 lib/quickbooks/dtd_parser.rb
quickbooks_api-0.0.4 lib/quickbooks/dtd_parser.rb