Skip to content
CAI
Software that uses CAICheck a score

makandra/active_type

65.3

Adequate · 20 September 2026

1.2k

lines of production code

Ruby

primary language

1

measurement over time

CAI band scale
CAI lens gauges

What this system is

ActiveType is a Ruby library that extends ActiveRecord models to support virtual attributes, type casting, and nested associations without requiring database persistence. It enables developers to create lightweight, in-memory model objects that mimic ActiveRecord behavior, including dirty tracking, validation, and Single-Table Inheritance. The system provides utilities to cast existing database records into these extended types while preventing post-cast mutations to ensure data integrity.

Features

ActiveType 2.8.0 introduces virtual attributes, casting, and Rails 7.2 compatibility

This release restructures the library into modular components to support new capabilities and broader framework compatibility. Users can now define virtual attributes on \ActiveType::Object\ and \ActiveType::Record\ subclasses, which support type casting, dirty tracking (\attribute\_changed?\), and YAML serialization. The new \ActiveType.cast\ utility allows casting existing ActiveRecord instances or relations into these extended types, while \change\_association\ enables modifying association scopes on casted records. Additionally, the library adds support for Rails 7.2, fixes marshalling for virtual attributes in Rails 7.1+, and drops support for Rails \< 5 and Ruby \< 2.7.

_lib/active\type · high confidence

Introduce ActiveType namespace with autoloaded Object, Record, and cast utility

The library now exposes a central \ActiveType\ module that automatically loads \ActiveType::Object\, \ActiveType::Record\, and \ActiveType::Util\ on demand. This structure makes the \ActiveType.cast\ method available directly on the namespace, allowing users to cast ActiveRecord instances and relations to extended models without requiring explicit requires for each component.

lib · high confidence

Support for nested attributes in ActiveType models

ActiveType models now support nested attributes for \nests\_one\ and \nests\_many\ associations, allowing users to assign and validate associated records via hash or array inputs. This change introduces the \nests\_one\ and \nests\_many\ DSL methods, enabling features such as automatic record building, destruction via \\_destroy\ flags, and error propagation to the parent model with optional indexed error keys for collection associations.

_lib/active\_type/nested\attributes · high confidence

Behavioural changes

ActiveType 2.8.0 release with Ruby 3.4 and Rails 8.1 support

This release updates the default development environment to Ruby 3.4 and adds compatibility testing for Rails 8.0 and 8.1 (including PostgreSQL and SQLite3 configurations). It also introduces the \attributes\_for\_inspect\ method on \ActiveType::Object\ and fixes serialization issues with \Marshal.dump/load\ for \ActiveType::Object\ and \ActiveType::Record\ introduced in version 2.6.5.

(repo-wide) · high confidence

Improved Single-Table Inheritance (STI) handling for extended ActiveType records

The library now correctly manages STI scenarios when extending ActiveRecord models. Specifically, it fixes the \model\_name\ and \i18n\_key\ generation so that extended records derive their identity from the extended class rather than the base class, ensuring correct routing and parameter naming. Additionally, the \find\_sti\_class\ method has been overridden to properly instantiate subclasses when querying through an extended base class, resolving issues where STI lookups would fail or return incorrect types for derived models.

_lib/active\_type/record\extension · high confidence

Fixes

Prevent mutation of records after casting

ActiveType now raises a MutationAfterCastError when attempting to modify attributes on a record after it has been cast. This change introduces an UnmutableAttributes wrapper that allows read-only access (such as for inspection or attribute retrieval) while blocking any write operations, ensuring that the original record state remains stable and preventing unexpected side effects from post-cast modifications.

_lib/active\type/util · high confidence

Test coverage

Added integration tests for form and model behaviors; Added isolated spec helper and updated spec configuration; Added isolated specs for ActiveType loading and coercion behavior; Added shared test suites for virtual attribute behavior; Added test coverage for ActiveType features; Added test support infrastructure for database and validation helpers; Added tests for Single Table Inheritance (STI) with extended records.

Dependencies

Modernize gemspec and update dependency requirements

The gemspec has been updated to require Ruby 2.7.0 or higher and ActiveRecord 6.1 or higher, dropping support for older versions. Development dependencies for bundler and rake are explicitly defined, and gem metadata including source code, bug tracker, and changelog URIs has been added. The file inclusion logic now strictly limits packaged files to lib, LICENSE, README.md, and CHANGELOG.md, excluding test directories from the built gem. Additionally, symlinks for Gemfile and Gemfile.lock now point to version-specific variants (Gemfile.8.0.sqlite3).

(dependencies) · high confidence

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Baseline

  • First survey — no prior run to compare against. CAI 65.

Lenses

  • Code Health 99
  • Architecture 69
  • Maturity 55
  • Readiness 65
  • Security 93
  • Domain Modelling 100

Changes since last survey

  • 300 commits — 240 feature/other, 60 fixes

By area

  • (root) — 142 commits
  • lib/active_type — 72 commits
  • (repo) — 31 commits
  • spec/active_type — 21 commits
  • .github/workflows — 10 commits
  • gemfiles/Gemfile.3.2.mysql2.lock — 9 commits
  • spec/integration — 3 commits
  • spec/shared_examples — 3 commits
  • gemfiles/Gemfile.3.2.mysql2 — 2 commits
  • lib/active_type.rb — 2 commits
  • spec/spec_helper.rb — 2 commits
  • gemfiles/Gemfile.5.0.0.mysql2 — 1 commit
  • spec/isolated — 1 commit
  • spec/support — 1 commit

Notable commits

  • fix: Add spec and fix constantize
  • fix: Change regex pattern and fix ruby warning
  • fix: Fix MutationAfterCastError on #attributes for records after casting
  • fix: Fix a ruby warning due to redundant regex pattern
  • fix: Fix aliassing ar_attribute method
  • fix: Fix belongs_to association validation for virtual attributes
  • fix: Fix change_association with polymorphic association
  • fix: Fix changelog
  • fix: Fix code block highlighting
  • fix: Fix indent. Fix syntax highlighting. [ci skip]
  • fix: Fix marshalling for virtual attributes on ActiveType::Object and ActiveType::Record
  • fix: Fix nests_one association record building
  • fix: Fix record lookup when id is given as string
  • fix: Fix record lookup when id is given as string
  • fix: Fix specs for Rails 7.1
  • fix: Fix testing failures in shape_spec.rb
  • fix: Fixed hash/array brackets in README's example
  • fix: Issue #142: Fix model name and I18n key when extending already extended records
  • fix: Issue #168: Fix change_association with only a scope proc
  • fix: Merge branch 'bugfix/derived-sti' of https://github.com/fsateler/active_type into fsateler-bugfix/derived-sti
  • …and 280 more

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

makandra/active_type was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 20 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit 55eaa1dc9ba9647d9d7933f28caa77a57a114bf0 — the exact code this score is about.
  • Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
  • Measured by watchdog.canine.dev using codehealth-analyzer preprod-b51f968c9b10.