Module: Fortnox::Serialisation::CollectionJSON

Included in:
Collection
Defined in:
lib/fortnox/serialisation.rb

Instance Method Summary collapse

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(options = nil)
  rendered = to_a.map do |item|
    Serialisation.json_safe(Serialisation.filter(item.model.attributes, options))
  end
  ::JSON.generate(rendered)
end