Skip to content
CAI
Software that uses CAICheck a score

DmitryTsepelev/store_model

71.0

Strong · 20 September 2026

1.9k

lines of production code

Ruby

primary language

1

measurement over time

CAI band scale
CAI lens gauges

What this system is

This system is a Ruby gem that enables the definition of embedded, value-object-like models within ActiveRecord attributes, supporting single, collection, and hash-based storage structures. It provides a robust type system for serialization and polymorphism, allowing for complex nested data handling with configurable error merging strategies and validation contexts. The library also extends functionality with enum support, nested attribute management, and compatibility layers for tools like ActiveAdmin.

Features

Added parent tracking and ActiveAdmin compatibility extensions

StoreModel now automatically tracks the parent record for nested model instances via new extension files in lib/store\_model/ext. The ParentAssignment module hooks into ActiveModel and ActiveRecord attribute read/write methods to set the parent reference on StoreModel instances, arrays, and hashes. Additionally, a new ActiveAdminCompatibility module provides reflection and new\_record? patches to ensure StoreModel works correctly with ActiveAdmin's form builders.

_lib/store\model/ext · high confidence

Added union type support for polymorphic attributes

The library now provides a \union\ method to create union types for polymorphic attributes, allowing users to define attributes that can be one of several classes based on a discriminator value. This feature includes validation to ensure all specified classes have the required discriminator attribute set and that discriminator values are unique, raising clear errors for missing or duplicate configurations.

lib · high confidence

StoreModel 4.6.1 introduces enums, nested attributes, and configuration options

This release upgrades the library to version 4.6.1, introducing several new capabilities and configuration options. Users can now define Rails-like enums with \enum\ support, including custom prefixes, suffixes, and invalid value handling. Nested attributes are now fully supported via \accepts\_nested\_attributes\_for\, allowing for \allow\_destroy\ and \update\_only\ behaviors on StoreModel attributes. The library also adds a new configuration system with options to control error merging strategies (\merge\_errors\, \merge\_array\_errors\, \merge\_hash\_errors\), serialization of unknown and empty attributes, enum serialization in \as\_json\, parent tracking, and ActiveAdmin compatibility. Additionally, the old \JsonModelType\ has been removed in favor of a more robust type system (\Types::One\, \Types::Many\, etc.), and various convenience methods like \from\_value\, \fetch\, and bracket access (\\[\]\) have been added to the model interface.

_lib/store\model · high confidence

Behavioural changes

Introduces dedicated type system for serialization, polymorphism, and enums

The \lib/store\_model/types\ directory now contains a comprehensive set of \ActiveModel::Type::Value\ implementations that define how StoreModel data is cast, serialized, and deserialized. This includes \EnumType\ for handling Rails-like enums with configurable invalid-value behavior, \One\, \Many\, and \Hash\ types for standard single, collection, and key-value storage, and corresponding \\*Polymorphic\ variants (\OnePolymorphic\, \ManyPolymorphic\, \HashPolymorphic\) that allow dynamic model resolution via a wrapper proc. The implementation also introduces \OneOf\ as a factory for these polymorphic types and \RawJSONEncoder\ to prevent duplicate JSON serialization on nested objects, fundamentally changing how store model attributes interact with the database and JSON payloads.

_lib/store\model/types · high confidence

Refined error merging strategies for StoreModel attributes

The error combination logic for StoreModel attributes has been updated to provide more granular control and better compatibility with Rails 6.1+. A new MergeArrayErrorStrategy now prefixes errors with array indices (e.g., "\[0\] error message") when merging errors from an array of models, while a new MergeHashErrorStrategy prefixes errors with hash keys. The existing MergeErrorStrategy has been rewritten to handle Rails 6.1+ differently, adding errors to the parent attribute with full messages instead of using the deprecated \copy!\ method, and the MarkInvalidErrorStrategy now attaches the child model's errors object to the parent attribute for more detailed validation feedback. Additionally, the module namespace was corrected from \CombileErrorsStrategies\ to \CombineErrorsStrategies\.

_lib/store\_model/combine\_errors\strategies · high confidence

StoreModelValidator now validates JSON, Array, and Hash attribute types

The StoreModelValidator has been updated to support validation of attributes typed as JSON, Array, and Hash (including polymorphic variants). Previously, it only handled basic StoreModel attributes; now it delegates to specific strategies for each type, ensuring that invalid elements in arrays or hashes are properly detected and merged into the parent record's errors, while also respecting the validation context.

_lib/active\model · high confidence

Test coverage

Added comprehensive tests for StoreModelValidator behavior; Added test configuration for parent assignment feature; Added test coverage for store model type casting and serialization; Added test fixtures and updated Configuration model for spec/dummy; Added tests for array error merging and fixed class name typo in error strategy specs; Benchmark for \_read\_attribute parent assignment optimization; Expanded test coverage for StoreModel features; Updated dummy database schema for test fixtures; Updated test configuration for enum serialization and JRuby compatibility.

Dependencies

Expanded CI support for Rails 7.2, 8.0, 8.1, and JRuby

The gemfile configuration for continuous integration has been updated to test against newer versions of the Rails framework and the JRuby runtime. New gemfiles have been added to support Rails 8.0 and 8.1, while the existing configuration for Rails 5.2 has been renamed and upgraded to target Rails 7.2. Additionally, a dedicated gemfile for JRuby has been introduced to ensure compatibility with that platform, and the master branch configuration now explicitly targets the 'main' branch of the Rails repository.

gemfiles · high confidence

Upgrade to Ruby 3.0+ and ActiveRecord 7.0

The gem now requires Ruby 3.0 or higher and depends on ActiveRecord 7.0 or higher, dropping support for older Ruby and Rails versions. The SQLite3 dependency has been updated to version 1.7.0, and the Rubocop development dependency is pinned to version 1.65.1.

(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 71.

Lenses

  • Code Health 100
  • Architecture 99
  • Maturity 58
  • Readiness 65
  • Security 97
  • Domain Modelling 100

Changes since last survey

  • 245 commits — 209 feature/other, 36 fixes

By area

  • (root) — 134 commits
  • lib/store_model — 49 commits
  • .github/workflows — 13 commits
  • (repo) — 12 commits
  • spec/store_model — 12 commits
  • docs/enums.md — 4 commits
  • docs/validations.md — 4 commits
  • docs/unknown_attributes.md — 3 commits
  • spec/dummy — 3 commits
  • docs/nested_models.md — 2 commits
  • benchmark/read_attribute_benchmark.rb — 1 commit
  • docs/one_of.md — 1 commit
  • gemfiles/jruby.gemfile — 1 commit
  • gemfiles/rails_6_0.gemfile — 1 commit
  • gemfiles/rails_8_1.gemfile.lock — 1 commit
  • gemfiles/railsmaster.gemfile — 1 commit
  • lib/active_model — 1 commit
  • lib/store_model.rb — 1 commit
  • spec/spec_helper.rb — 1 commit

Notable commits

  • fix: Add changelog entry and fix :cop:
  • fix: CI: fix test to work in JRuby and add Ruby 3.2 to the matrix (#137)
  • fix: Fix :unknown_attributes assignment for ArrayType (#34)
  • fix: Fix CI (#155)
  • fix: Fix CI (#201)
  • fix: Fix CI for JRuby (#165)
  • fix: Fix JRuby CI (#96)
  • fix: Fix JRuby CI failure (#90)
  • fix: Fix accepts_nested_attributes_for with allow_destroy: true raising error when database is not initialized or table for model doesnt exist (#163)
  • fix: Fix crash in presence validator
  • fix: Fix defaults issue (#148)
  • fix: Fix for AR association accepts_nested_attributes_for and a raise_if proc (#196)
  • fix: Fix infinite loop with nested model and :attributes key (#79)
  • fix: Fix inspect output for falsey values (#38)
  • fix: Fix issue with serialization options not applied to nested objects (#171)
  • fix: Fix rubocop, update changelog
  • fix: Fix rubocop, update changelog
  • fix: Fix saving unknown_attributes (#108)
  • fix: Fix serialization on nested objects (#154)
  • fix: Fix syntax errors in code blocks in documentation (#43)
  • …and 225 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

DmitryTsepelev/store_model 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 c868dc0f3edc15ff20d8b5305280742452cdc2b3 — 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.