Serega Guides
Each guide covers one feature in depth. For a one-page overview of every option, see the Cheatsheet.
Basics
-
Attributes — define serializers, attributes and relations
-
Serializing —
to_h,to_struct,to_data -
Root Key and Metadata — wrap results in
{data: ...}and add metadata -
Selecting Fields —
:only,:except,:with -
Context — pass
current_userand other request data -
Conditional Attributes —
:if,:unless,:if_value,:unless_value -
Formatters — format dates, money and other values
Loading data without N+1
-
Preloads — preload associations used by requested fields
-
Batch Loading — load data for all serialized objects at once
Data sources
-
Hash Records — read attribute values from Hash keys
-
Prepare Initial Objects — serialize records by ids
-
Presenter — write computed attributes as methods
Advanced
-
Configuration — all config options
-
Ractors — serialize in parallel Ractors