Skip to content

Commit b1d9ca6

Browse files
committed
docs(readme): document the image type shortcut
1 parent ad0bf8d commit b1d9ca6

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

‎README.md‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ accepts these nested keys under `filters[<name>]`:
225225
| Key | Meaning |
226226
|------------------------|----------------------------------------------------|
227227
| `present` | strict true or bare key → attached; explicit false (`'false'`, `'0'`) → unattached |
228-
| `type` | blob content type — scalar `=`, array `IN` |
228+
| `type` | blob content type — scalar `=`, array `IN`, or the `image` shortcut |
229229
| `min_size` / `max_size`| inclusive blob byte size bounds |
230230

231231
```ruby
@@ -237,8 +237,15 @@ end
237237

238238
Contract.filterable(filters: { document: { present: true } })
239239
Contract.filterable(filters: { document: { type: %w[application/pdf image/png], max_size: 5_000_000 } })
240+
Contract.filterable(filters: { document: { type: 'image' } })
240241
```
241242

243+
The `image` shortcut expands at query time against
244+
`ActiveStorage.variable_content_types` + `web_image_content_types` (a real
245+
content type always carries a slash, so the name is unambiguous), and composes
246+
inside arrays next to literal types. An unknown literal stays a plain equality
247+
that matches nothing; an unknown symbol narrows nothing.
248+
242249
Everything resolves through the associations `has_one_attached` /
243250
`has_many_attached` generate, so the gem still has no ActiveStorage
244251
dependency; a declared name without those associations narrows nothing, and

0 commit comments

Comments
 (0)