Module: Filterable::Attachable

Defined in:
lib/filterable/attachable.rb

Overview

Filters records by their ActiveStorage attachments, declared with attachable :document. Reads these nested keys under filters[<name>]: present (strict true or bare key keeps attached records, an explicit false keeps unattached ones), type (blob content type, = or IN), min_size / max_size (inclusive blob byte size bounds).

Everything resolves through the associations has_one_attached / has_many_attached generate (+_attachment(s)+, <name>_blob(s) — Rails' documented contract), so the gem never references ActiveStorage itself; a declared name without those associations narrows nothing.

Constant Summary collapse

TYPE_SHORTCUTS =

The symbolic type shortcuts, each expanded lazily at query time against ActiveStorage's configured content-type lists — never frozen at boot, and only ever called once the model proved it has real attachments, so the gem still loads without ActiveStorage.

{
  'image' => -> { ActiveStorage.variable_content_types | ActiveStorage.web_image_content_types }
}.freeze