Module: Graft::Xml::Model::InstanceMethods
- Defined in:
- lib/graft/lib/graft/xml/model.rb
Instance Method Summary collapse
Instance Method Details
#to_hash ⇒ Object
23 24 25 |
# File 'lib/graft/lib/graft/xml/model.rb', line 23 def to_hash self.class.attributes.inject({}) {|h,a| h.merge(a.name.to_s => send(a.name)) } end |
#to_xml(tag_name) ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/graft/lib/graft/xml/model.rb', line 27 def to_xml(tag_name) xml = Builder::XmlMarkup.new xml.instruct! xml.tag! tag_name do to_hash.each do |attribute, value| xml.tag! attribute, value end end xml.target! end |