Commit 6334ed3
Add compact_blank polyfill for Rails 5.2-6.0 compatibility
The previous commit added `require "active_support/core_ext/enumerable"` but
this doesn't provide `compact_blank` on Rails < 6.1 because that method was
only introduced in Rails 6.1.
This commit adds a proper polyfill that:
1. Checks if compact_blank already exists (Rails 6.1+)
2. If not, defines it on both Enumerable and Array using reject(&:blank?)
3. Also requires "active_support/core_ext/object/blank" for the blank? method
The polyfill correctly mirrors Rails 6.1+ behavior:
- Removes nil, empty strings (""), whitespace strings (" ")
- Removes false (since false.blank? == true in ActiveSupport)
- Keeps truthy values like non-empty strings, true, numbers
This ensures the gem works correctly on all supported Rails versions (>= 5.2).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>1 parent 0dc07ac commit 6334ed3
1 file changed
+16
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
4 | 20 | | |
5 | 21 | | |
6 | 22 | | |
| |||
0 commit comments