Module: DataMapper::Serialize
- Defined in:
- lib/dm-serializer/common.rb,
lib/dm-serializer/to_xml.rb,
lib/dm-serializer/xml_serializers.rb,
lib/dm-serializer/xml_serializers/rexml.rb,
lib/dm-serializer/xml_serializers/libxml.rb,
lib/dm-serializer/xml_serializers/nokogiri.rb
Defined Under Namespace
Modules: XMLSerializers Classes: Support
Instance Method Summary collapse
-
#properties_to_serialize(options) ⇒ Array
Returns propreties to serialize based on :only or :exclude arrays, if provided :only takes precendence over :exclude.
-
#to_xml(opts = {}) ⇒ REXML::Document
Serialize a Resource to XML.
Instance Method Details
#properties_to_serialize(options) ⇒ Array
Returns propreties to serialize based on :only or :exclude arrays, if provided :only takes precendence over :exclude
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/dm-serializer/common.rb', line 7 def properties_to_serialize() only_properties = Array([:only]) excluded_properties = Array([:exclude]) model.properties(repository.name).reject do |p| if only_properties.include? p.name false else excluded_properties.include?(p.name) || !(only_properties.empty? || only_properties.include?(p.name)) end end end |
#to_xml(opts = {}) ⇒ REXML::Document
Serialize a Resource to XML
10 11 12 13 |
# File 'lib/dm-serializer/to_xml.rb', line 10 def to_xml(opts = {}) xml = XMLSerializers::SERIALIZER xml.output(to_xml_document(opts)).to_s end |