Sha256: 7c65dfd261b04c7d5d363e8751edb6b21f546d9dad937611a96fab56161de5f5
Contents?: true
Size: 924 Bytes
Versions: 3
Compression:
Stored size: 924 Bytes
Contents
module SAXMachine def self.configure(clazz) extended_clazz = Class.new(clazz) extended_clazz.send(:include, SAXMachine) # override create_attr to create attributes on the original class def extended_clazz.create_attr real_name superclass.send(:attr_reader, real_name) unless superclass.method_defined?(real_name) superclass.send(:attr_writer, real_name) unless superclass.method_defined?("#{real_name}=") end yield(extended_clazz) clazz.extend LightWeightSaxMachine clazz.sax_config = extended_clazz.sax_config (class << clazz;self;end).send(:define_method, :parse) do |xml_input| extended_clazz.parse(xml_input) end end module LightWeightSaxMachine attr_writer :sax_config def sax_config @sax_config ||= SAXConfig.new end def inherited(subclass) subclass.sax_config.send(:initialize_copy, self.sax_config) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
sax-machine-1.3.2 | lib/sax-machine/sax_configure.rb |
sax-machine-1.3.1 | lib/sax-machine/sax_configure.rb |
sax-machine-1.3.0 | lib/sax-machine/sax_configure.rb |