Module: Graft::Xml::Model::ClassMethods
- Defined in:
- lib/graft/lib/graft/xml/model.rb
Instance Method Summary collapse
Instance Method Details
#attribute(name, options = {}) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/graft/lib/graft/xml/model.rb', line 7 def attribute(name, = {}) source = [:from] type = [:type] || :string self.attributes << Graft::Xml::Attribute.new(name, type, source) class_eval "attr_accessor :#{name}" end |
#data_from(xml_or_document) ⇒ Object
15 16 17 |
# File 'lib/graft/lib/graft/xml/model.rb', line 15 def data_from(xml_or_document) xml_or_document.is_a?(String) ? Hpricot.XML(xml_or_document) : xml_or_document end |