Module: Representable::XML
- Included in:
- AttributeHash, Collection, Hash
- Defined in:
- lib/representable/xml.rb,
lib/representable/xml/hash.rb,
lib/representable/xml/collection.rb,
lib/representable/bindings/xml_bindings.rb
Defined Under Namespace
Modules: AttributeHash, ClassMethods, Collection, Hash
Classes: AttributeBinding, AttributeHashBinding, CollectionBinding, ContentBinding, HashBinding, PropertyBinding
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.included(base) ⇒ Object
7
8
9
10
11
12
13
|
# File 'lib/representable/xml.rb', line 7
def self.included(base)
base.class_eval do
include Representable
extend ClassMethods
self.representation_wrap = true end
end
|
Instance Method Details
#from_node(node, options = {}) ⇒ Object
48
49
50
|
# File 'lib/representable/xml.rb', line 48
def from_node(node, options={})
update_properties_from(node, options, PropertyBinding)
end
|
#from_xml(doc, *args) ⇒ Object
42
43
44
45
46
|
# File 'lib/representable/xml.rb', line 42
def from_xml(doc, *args)
node = parse_xml(doc, *args)
from_node(node, *args)
end
|
#to_node(options = {}) ⇒ Object
Returns a Nokogiri::XML object representing this object.
53
54
55
56
57
58
|
# File 'lib/representable/xml.rb', line 53
def to_node(options={})
options[:doc] ||= Nokogiri::XML::Document.new
root_tag = options[:wrap] || representation_wrap
create_representation_with(Nokogiri::XML::Node.new(root_tag.to_s, options[:doc]), options, PropertyBinding)
end
|
#to_xml(*args) ⇒ Object
60
61
62
|
# File 'lib/representable/xml.rb', line 60
def to_xml(*args)
to_node(*args).to_s
end
|