Sha256: 7cd52c6a4c85471dacb62d1faf80cf7eeba6293267dcc43cf45b6853383afe06
Contents?: true
Size: 987 Bytes
Versions: 11
Compression:
Stored size: 987 Bytes
Contents
$:.unshift File.dirname __FILE__ require 'model_xml/generator' module ModelXML def self.included base base.instance_eval do def model_xml *args, &block @model_xml_generator ||= ModelXML::Generator.new if block_given? @model_xml_generator.add_field_set(*args, &block) else @model_xml_generator.add_field_set *args end end # this is probably only ever required for testing def model_xml_reset! @model_xml_generator = ModelXML::Generator.new end def model_xml_generator @model_xml_generator end end end def to_xml options={} # if no generator is defined, pass straight through to the parent to_xml method, which may or may not exist if generator = self.class.model_xml_generator generator.generate_xml! self, options else super options end end end ActiveRecord::Base.send :include, ModelXML if defined?(ActiveRecord::Base)
Version data entries
11 entries across 11 versions & 1 rubygems