Skip to content

Modernize Ruby idioms in Configuration and tsearch#572

Merged
nertzy merged 3 commits into
masterfrom
modernize-ruby-idioms
May 22, 2026
Merged

Modernize Ruby idioms in Configuration and tsearch#572
nertzy merged 3 commits into
masterfrom
modernize-ruby-idioms

Conversation

@nertzy
Copy link
Copy Markdown
Collaborator

@nertzy nertzy commented May 22, 2026

Summary

  • Replace reduce({}) + hash.tap hash builders in tsearch's headline_options and deprecated_headline_options with to_h and each_with_object — the previous form yielded the accumulator and assigned into it, which is what to_h / each_with_object express directly.
  • Build Configuration#feature_options with features.to_h { ... } instead of {}.tap { features.map { ... } }. As a bonus this also removes the latent oddity that map was used purely for its side effect.
  • Convert one-liner accessors in Configuration (columns, query, ignore, ranking_sql, features, associated_columns, order_within_rank) to endless method syntax now that Ruby 3.3 is the floor.

Test plan

  • bin/rspec passes (254 examples, 0 failures locally)
  • bin/standardrb is clean

🤖 Generated with Claude Code

nertzy added 3 commits May 22, 2026 13:58
The pattern reduce({}) { |hash, k| hash.tap { hash[k] = v } } is an
anti-idiom: when the accumulator is the same hash being yielded each
iteration, each_with_object expresses intent more directly, and to_h
with a block does so even better when there are no conditionals.
The previous form used {}.tap with features.map and assigned into the
captured hash, which is the long way to write to_h. As a bonus, this
also removes the latent oddity that map was used purely for its side
effect.
Single-expression accessors in Configuration read better as endless
methods. Multi-line bodies, methods with guards (regular_columns,
associations), and the now-multi-line feature_options are left alone.
@nertzy nertzy merged commit acb29da into master May 22, 2026
14 checks passed
@nertzy nertzy deleted the modernize-ruby-idioms branch May 22, 2026 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant