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
Copy file name to clipboardExpand all lines: README.md
+50Lines changed: 50 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -68,6 +68,56 @@ class User < ApplicationRecord
68
68
end
69
69
```
70
70
71
+
### Void Objects
72
+
73
+
While `Null` objects are singletons (one instance per model), `Void` objects are instantiable null objects that allow creating multiple instances with different attribute values.
Void objects support the same features as Null objects:
114
+
- Callable defaults (lambdas/procs)
115
+
- Custom methods via block syntax
116
+
- Association handling
117
+
- All ActiveRecord query methods (`null?`, `persisted?`, etc.)
118
+
119
+
Use `Null` when you need a single shared null object instance. Use `Void` when you need multiple null object instances with different attribute values.
120
+
71
121
## Development
72
122
73
123
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
0 commit comments