|
| 1 | +# Context Objects |
| 2 | + |
| 3 | +Context objects are the arguments passed to APIs like [field blocks](../dsl/fields.md#field-blocks), [option procs](../dsl/options.md) and [extension hooks](./extensions.md). There are several kinds of context objects, each with its own set of fields. |
| 4 | + |
| 5 | +## Render Context |
| 6 | + |
| 7 | +_* Field can be assigned._ |
| 8 | + |
| 9 | +> **blueprint** \ |
| 10 | +> The current Blueprint instance. You can use this to access the Blueprint's name, options, reflections, and instance methods. |
| 11 | +
|
| 12 | +> **fields** * \ |
| 13 | +> A frozen array of field definitions that will be serialized, in order. See [Fields API](./fields.md). |
| 14 | +
|
| 15 | +> **options** * \ |
| 16 | +> The frozen options Hash passed to `render`. An empty Hash if none was passed. |
| 17 | +
|
| 18 | +> **store** \ |
| 19 | +> A Hash that can be used to store & access information by extensions and your application. |
| 20 | +
|
| 21 | +> **depth** \ |
| 22 | +> The current blueprint depth (1-indexed). |
| 23 | +
|
| 24 | +## Object Context |
| 25 | + |
| 26 | +_* Field can be assigned._ |
| 27 | + |
| 28 | +> **blueprint** \ |
| 29 | +> The current Blueprint instance. You can use this to access the Blueprint's name, options, reflections, and instance methods. |
| 30 | +
|
| 31 | +> **fields** \ |
| 32 | +> A frozen array of field definitions that will be serialized, in order. See [Fields API](./fields.md) and the [blueprint_fields](./extensions.md#blueprint_fields) hook. |
| 33 | +
|
| 34 | +> **options** \ |
| 35 | +> The frozen options Hash passed to `render`. An empty Hash if none was passed. |
| 36 | +
|
| 37 | +> **object** * \ |
| 38 | +> The object or collection currently being serialized. |
| 39 | +
|
| 40 | +> **store** \ |
| 41 | +> A Hash that can be used to store & access information by extensions and your application. |
| 42 | +
|
| 43 | +> **depth** \ |
| 44 | +> The current blueprint depth (1-indexed). |
| 45 | +
|
| 46 | +## Field Context |
| 47 | + |
| 48 | +> **blueprint** \ |
| 49 | +> The current Blueprint instance. You can use this to access the Blueprint's name, options, reflections, and instance methods. |
| 50 | +
|
| 51 | +> **fields** \ |
| 52 | +> A frozen array of field definitions that will be serialized, in order. See [Fields API](./fields.md) and the [blueprint_fields](./extensions.md#blueprint_fields) hook. |
| 53 | +
|
| 54 | +> **options** \ |
| 55 | +> The frozen options Hash passed to `render`. An empty Hash if none was passed. |
| 56 | +
|
| 57 | +> **object** \ |
| 58 | +> The object currently being serialized. |
| 59 | +
|
| 60 | +> **field** \ |
| 61 | +> A struct of the field, object, or collection currently being rendered. You can use this to access the field's name and options. See [Fields API](./fields.md). |
| 62 | +
|
| 63 | +> **store** \ |
| 64 | +> A Hash that can be used to store & access information by extensions and your application. |
| 65 | +
|
| 66 | +> **depth** \ |
| 67 | +> The current blueprint depth (1-indexed). |
| 68 | +
|
| 69 | +## Result Context |
| 70 | + |
| 71 | +_* Field can be assigned._ |
| 72 | + |
| 73 | +> **blueprint** * \ |
| 74 | +> The current Blueprint instance. You can use this to access the Blueprint's name, options, reflections, and instance methods. |
| 75 | +
|
| 76 | +> **fields** \ |
| 77 | +> A frozen array of field definitions that were serialized, in order. See [Fields API](./fields.md) and the [around_blueprint_init](./extensions.md#around_blueprint_init) hook. |
| 78 | +
|
| 79 | +> **options** * \ |
| 80 | +> The frozen options Hash passed to `render`. An empty Hash if none was passed. |
| 81 | +
|
| 82 | +> **object** * \ |
| 83 | +> The object or collection that was just serialized. |
| 84 | +
|
| 85 | +> **store** \ |
| 86 | +> A Hash that can be used to store & access information by extensions and your application. |
| 87 | +
|
| 88 | +> **format** * \ |
| 89 | +> The requested serialization format (e.g. `:json`, `:hash`). |
| 90 | +
|
| 91 | +## Hook Context |
| 92 | + |
| 93 | +> **blueprint** \ |
| 94 | +> The current Blueprint instance. You can use this to access the Blueprint's name, options, reflections, and instance methods. |
| 95 | +
|
| 96 | +> **fields** \ |
| 97 | +> A frozen array of field definitions that will be serialized, in order. See [Fields API](./fields.md) and the [around_blueprint_init](./extensions.md#around_blueprint_init) hook. |
| 98 | +
|
| 99 | +> **options** \ |
| 100 | +> The frozen options Hash passed to `render`. An empty Hash if none was passed. |
| 101 | +
|
| 102 | +> **extension** \ |
| 103 | +> Instance of the current extension |
| 104 | +
|
| 105 | +> **hook** \ |
| 106 | +> Name of the current hook |
| 107 | +
|
| 108 | +> **store** \ |
| 109 | +> A Hash that can be used to store & access information by extensions and your application. |
| 110 | +
|
| 111 | +> **depth** \ |
| 112 | +> The current blueprint depth (1-indexed). |
0 commit comments