Module: Knuckles::Stages::Renderer
Overview
After un-cached models have been hydrated they can be rendered. Rendering is synonymous with converting a model to a hash, like calling ‘as_json` on an `ActiveRecord` model. Knuckles provides a minimal (but fast) view module that can be used with the rendering step. Alternatively, if you’re migrating from ‘ActiveModelSerializers` you can pass in an AMS class instead.
Instance Method Summary collapse
-
#call(objects, options) ⇒ Object
Serialize all un-cached objects into hashes.
Instance Method Details
#call(objects, options) ⇒ Object
Serialize all un-cached objects into hashes.
33 34 35 36 37 38 39 40 41 |
# File 'lib/knuckles/stages/renderer.rb', line 33 def call(objects, ) view = .fetch(:view) objects.each do |hash| unless hash[:cached?] hash[:result] = do_render(hash[:object], view, ) end end end |