Skip to content

feat: v2.0.0 — drop Virtus, modernize gem for Rails 8#1

Merged
Mechetel merged 1 commit into
masterfrom
feat/v2-modernize-drop-virtus
May 13, 2026
Merged

feat: v2.0.0 — drop Virtus, modernize gem for Rails 8#1
Mechetel merged 1 commit into
masterfrom
feat/v2-modernize-drop-virtus

Conversation

@Mechetel
Copy link
Copy Markdown
Owner

Summary

  • Drop Virtus (abandoned since ~2016) and its stale transitive deps (axiom-types, coercible, descendants_tracker) — replaced with a custom Rectify::Attributable module that uses plain Ruby with zero new dependencies
  • Replace eval() in Command#evaluate with block.binding.receiver (Ruby 2.6+) — safer, no security smell
  • Replace OpenStruct for form context with a lightweight Rectify::Context class
  • Fix Rails 8 SQLite adapter compatDatabaseReporter now ignores sqlite_version() queries emitted by Rails 8 on first connection, which previously broke the query-count spec
  • Bump version to 2.0.0 (breaking: Virtus removed from runtime deps)

What Rectify::Attributable provides

  • attribute :name, String — typed scalar attributes with coercion (Integer, Float, String, Symbol)
  • attribute :address, AddressForm — nested form coercion from Hash
  • attribute :contacts, [ContactForm] — array of typed/form objects
  • attribute :colours, Array — untyped array pass-through
  • attribute :email — untyped attribute (no coercion)
  • String and symbol key initialization (both work)
  • attribute_set introspection (used by BuildFormFromModel, FormatAttributesHash)
  • Inherited attributes — subclasses get parent attributes via dup

Test plan

  • All 114 existing specs pass unchanged
  • bundle exec rubocop — no offenses
  • bundle install resolves without Virtus

Install after merge

# Gemfile — pin to release tag
gem 'rectify', github: 'Mechetel/rectify', tag: 'v2.0.0'

🤖 Generated with Claude Code

- Replace abandoned Virtus library with custom Rectify::Attributable
  module backed by plain Ruby (no external dep), supporting typed
  attributes, type coercion, nested forms, and array-of-form attributes
- Add Rectify::AttributeDefinition replacing Virtus::Attribute introspection
- Add Rectify::Context (struct-like) replacing OpenStruct for form context
- Remove eval() in Command#evaluate — use block.binding.receiver instead
- Update FormAttribute, BuildFormFromModel, FormatAttributesHash to use
  new attribute_set API
- Fix DatabaseReporter SQL_TO_IGNORE to exclude sqlite_version() query
  emitted by Rails 8 SQLite adapter on first connection
- Remove virtus (~> 2.0) and its stale transitive deps (axiom-types,
  coercible, descendants_tracker) from gemspec
- Bump version to 2.0.0
- All 114 specs pass, rubocop clean

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Mechetel Mechetel merged commit 7b390d9 into master May 13, 2026
2 checks passed
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