You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enhance as_json for pointer collections and objects
Adds support for the :pointers_only option to PointerCollectionProxy#as_json, allowing serialization of full objects or pointers as needed. Parse::Object#as_json now always includes identification fields (objectId, className, __type, id) when using :only, unless :strict is true. Introduces :exclude as an alias for :except in as_json. Updates tests to cover new behaviors and documents changes in the changelog. Bumps version to 3.2.3.
Copy file name to clipboardExpand all lines: CHANGELOG.md
+49Lines changed: 49 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,54 @@
1
1
## Parse-Stack Changelog
2
2
3
+
### 3.2.3
4
+
5
+
#### Improvements
6
+
7
+
-**IMPROVED**: `PointerCollectionProxy#as_json` now supports the `pointers_only` option. By default it returns pointers (preserving backward compatibility), but you can set `pointers_only: false` to serialize objects with their fetched fields. This is useful when returning `has_many :through => :array` relationships in webhook responses.
8
+
9
+
When `pointers_only: false`:
10
+
- Partially hydrated objects serialize only their fetched fields (no autofetch triggered)
11
+
- Pointer-only objects (unfetched) remain as pointers
12
+
- Fully hydrated objects serialize all their fields
13
+
14
+
```ruby
15
+
# Default behavior - pointers for storage (backward compatible)
# In webhooks, manually override assets serialization:
24
+
cloud_results.map do |capture|
25
+
json = capture.as_json
26
+
json['assets'] = capture.assets.as_json(pointers_only:false) if capture.assets.any?
27
+
json
28
+
end
29
+
```
30
+
31
+
-**IMPROVED**: `Parse::Object#as_json` with `:only` option now automatically includes identification fields (`objectId`, `className`, `__type`, `id`) so serialized objects can always be properly identified. Use `strict: true` to disable this behavior for pure strict filtering.
32
+
33
+
```ruby
34
+
# Default: identification fields are always included
0 commit comments