Module: XMLable::Mixins::Export
- Defined in:
- lib/xmlable/mixins/export.rb
Overview
Export modules contains method to export
Instance Method Summary collapse
-
#to_h(opts = {}) ⇒ Hash
Export to hash.
-
#to_json(opts = {}) ⇒ String
Export to JSON.
-
#to_xml(opts = {}) ⇒ String
Export to XML.
Instance Method Details
#to_h(opts = {}) ⇒ Hash
Export to hash
40 41 42 |
# File 'lib/xmlable/mixins/export.rb', line 40 def to_h(opts = {}) Exports::JSONExporter.new(self, opts).export end |
#to_json(opts = {}) ⇒ String
Export to JSON
28 29 30 31 |
# File 'lib/xmlable/mixins/export.rb', line 28 def to_json(opts = {}) ret = to_h(opts) opts[:pretty] ? JSON.pretty_generate(ret) : ret.to_json end |
#to_xml(opts = {}) ⇒ String
Export to XML
14 15 16 17 18 |
# File 'lib/xmlable/mixins/export.rb', line 14 def to_xml(opts = {}) exporter = Exports::XMLExporter.new(self, opts) opts = self.class..merge(opts) exporter.export.to_xml(opts).strip end |