Module: Fortnox::Serialisation::CollectionJSON
- Included in:
- Collection
- Defined in:
- lib/fortnox/serialisation.rb
Instance Method Summary collapse
-
#to_json(options = nil) ⇒ Object
Renders as its records, the way an Array of them would.
Instance Method Details
#to_json(options = nil) ⇒ Object
Renders as its records, the way an Array of them would. Pagination metadata stays addressable on the collection for callers that want to render it alongside.
60 61 62 63 64 65 |
# File 'lib/fortnox/serialisation.rb', line 60 def to_json( = nil) rendered = to_a.map do |item| Serialisation.json_safe(Serialisation.filter(item.model.attributes, )) end ::JSON.generate(rendered) end |