Module: Representable::XML
- Included in:
- 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: ClassMethods, Collection, Hash, ObjectBinding
Classes: AttributeBinding, CollectionBinding, HashBinding, PropertyBinding
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.binding_for_definition(definition) ⇒ Object
.included(base) ⇒ Object
14
15
16
17
18
19
20
|
# File 'lib/representable/xml.rb', line 14
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
46
47
48
|
# File 'lib/representable/xml.rb', line 46
def from_node(node, options={})
update_properties_from(node, options, XML)
end
|
#from_xml(doc, *args) ⇒ Object
41
42
43
44
|
# File 'lib/representable/xml.rb', line 41
def from_xml(doc, *args)
node = Nokogiri::XML(doc).root
from_node(node, *args)
end
|
#to_node(options = {}) ⇒ Object
Returns a Nokogiri::XML object representing this object.
51
52
53
54
55
|
# File 'lib/representable/xml.rb', line 51
def to_node(options={})
root_tag = options[:wrap] || representation_wrap
create_representation_with(Nokogiri::XML::Node.new(root_tag.to_s, Nokogiri::XML::Document.new), options, XML)
end
|
#to_xml(*args) ⇒ Object
57
58
59
|
# File 'lib/representable/xml.rb', line 57
def to_xml(*args)
to_node(*args).to_s
end
|