Class: DataMapper::Collection
- Inherits:
-
Object
- Object
- DataMapper::Collection
- Defined in:
- lib/dm-serializer.rb
Overview
module Resource
Instance Method Summary collapse
- #to_csv ⇒ Object
- #to_json(opts = {}) ⇒ Object
- #to_xml(opts = {}) ⇒ Object
- #to_yaml(opts = {}) ⇒ Object
Instance Method Details
#to_csv ⇒ Object
150 151 152 153 154 155 156 |
# File 'lib/dm-serializer.rb', line 150 def to_csv result = "" each do |item| result << item.to_csv + "\n" end result end |
#to_json(opts = {}) ⇒ Object
142 143 144 |
# File 'lib/dm-serializer.rb', line 142 def to_json(opts = {}) "[" << map {|e| e.to_json(opts)}.join(",") << "]" end |
#to_xml(opts = {}) ⇒ Object
146 147 148 |
# File 'lib/dm-serializer.rb', line 146 def to_xml(opts = {}) to_xml_document(opts).to_s end |
#to_yaml(opts = {}) ⇒ Object
138 139 140 |
# File 'lib/dm-serializer.rb', line 138 def to_yaml(opts = {}) to_a.to_yaml(opts) end |