Module: Filterable::Togglable

Defined in:
lib/filterable/togglable.rb

Overview

Applies a no-argument model scope when filters[<name>] is present as a bare key (+?filters+, filters[priced]=) or carries a strict true value. Only names the model declared togglable are honored; the scope name is fixed at declaration time, never derived from the params. An explicit false value (+'false'+, '0' — what Rails' check_box hidden field submits), an arbitrary string, a missing scope, or a scope not returning a relation narrows nothing.

Constant Summary collapse

TRUE_VALUES =

The explicit values that switch a toggle on. A strict allowlist, unlike ActiveModel::Type::Boolean where any unrecognized string casts to true.

[true, 1, '1', 'true'].freeze
FALSE_VALUES =

The explicit values that switch a toggle off — what Rails' check_box hidden field submits. The shared vocabulary for every boolean-ish param in the gem.

[false, 0, '0', 'false'].freeze