Module: ROXML::InstanceMethods
- Defined in:
- lib/roxml.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#to_xml(params = {}) ⇒ Object
Returns an XML object representing this object.
Instance Method Details
#to_xml(params = {}) ⇒ Object
Returns an XML object representing this object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/roxml.rb', line 24 def to_xml(params = {}) params.reverse_merge!(:name => self.class.tag_name, :namespace => self.class.roxml_namespace) params[:namespace] = nil if ['*', 'xmlns'].include?(params[:namespace]) XML.new_node([params[:namespace], params[:name]].compact.join(':')).tap do |root| refs = (self.roxml_references.present? \ ? self.roxml_references \ : self.class.roxml_attrs.map {|attr| attr.to_ref(self) }) refs.each do |ref| value = ref.to_xml(self) unless value.nil? ref.update_xml(root, value) end end end end |