Skip to content
CAI
Software that uses CAICheck a score

amatsuda/active_decorator

64.1

Adequate · 20 September 2026

441

lines of production code

Ruby

primary language

1

measurement over time

CAI band scale
CAI lens gauges

What this system is

ActiveDecorator is a Ruby library that automatically applies decorators to Active Record associations, controller instance variables, and Action View render contexts. It provides generators for creating decorator classes and their corresponding tests, while ensuring thread safety and compatibility across various Rails and Ruby versions.

How it got here

2011 — Rails 6.1 compatibility and generator expansion

11 changes.

The project focused on updating ActiveDecorator for compatibility with Rails 6.1 and modern Ruby versions, including decoupling from strict Rails dependencies and improving thread safety. Significant features were added, such as a new decorator generator for creating classes and tests, and automatic decoration of controller instance variables and view render contexts.

2015–2025 — Active Record association decoration and test migration

8 changes.

The project introduced automatic decoration for Active Record associations by monkey-patching collection and association methods to preserve decoration markers. Concurrently, the test suite was migrated from RSpec to Test::Unit, accompanied by the addition of a comprehensive fixture Rails application and extensive integration tests for controller, model, and generator behaviors.

Features

Add decorator generator

Users can now generate decorator classes using the \rails g decorator\ command. This new generator creates a decorator module in the \app/decorators\ directory, supports class paths for nested structures, and automatically hooks into the configured test framework to generate corresponding test files.

lib/generators/rails · high confidence

Add decorator generator template with frozen string literal

A new template file for the Rails decorator generator has been added, providing the initial structure for a decorator module. The generated code now includes the \\# frozen\_string\_literal: true\ magic comment, ensuring that string literals in generated files are immutable by default, which improves performance and safety.

lib/generators/rails/templates · high confidence

Added test\_unit generator for decorators

A new generator has been added to the test\_unit namespace that creates test files for decorators. When invoked, it generates a test file at test/decorators/\[class\_path\]/\[file\_name\]\_decorator\_test.rb using a template from the generator's local templates directory, and includes a class collision check to prevent overwriting existing test classes.

_lib/generators/test\unit · high confidence

Behavioural changes

ActiveDecorator 1.5.1 release with warning fixes and thread-safety improvements

This release updates the CHANGELOG to document version 1.5.1, which removes an unnecessary \ruby2\_keywords\ call to eliminate a specific warning and fixes an 'assigned but unused variable' warning for \view\_context\_stack\. It also records the changes from version 1.5.0, where the library switched from using \Thread.current\ to \ActiveSupport::CurrentAttributes\ for storing the ViewContext to improve thread safety, and stopped dropping keyword arguments when delegating helper methods via \method\_missing\.

(repo-wide) · high confidence

ActiveDecorator version bump to 1.5.1

The library version has been updated from 0.0.1 to 1.5.1. This release includes support for Rails 6.1, improved handling of ActionView::CollectionRenderer and ObjectRenderer, and fixes for Ruby 2.7 keyword arguments and Jbuilder partial rendering.

_lib/active\decorator · high confidence

Auto-decorating Action View render locals and objects

ActiveDecorator now automatically applies decorators to values passed as locals, the object, and collections when rendering partials via Action View. This behavior is implemented by monkey-patching the PartialRenderer, ObjectRenderer, and CollectionRenderer modules, with version-specific logic to handle Rails 6.1+ (decorating in \initialize\) versus earlier versions (decorating in \setup\).

_lib/active\_decorator/monkey/action\view · high confidence

Auto-decorating instance variables in controller views

The library now automatically decorates instance variables passed to views by patching the AbstractController::Rendering module. When a controller renders a view, any instance variables (ivars) included in the view context are now passed through the decorator instance, ensuring that decorated objects are available in the view without manual intervention.

_lib/active\_decorator/monkey/abstract\controller · high confidence

Auto-decoration of Active Record associations and collection methods

The library now automatically decorates associated records when accessed via Active Record associations. This is achieved by monkey-patching \Association\#target\, \CollectionProxy\#take\, and, for Rails 5.1+, \CollectionProxy\#last\, \find\_nth\_with\_limit\, and \find\_nth\_from\_last\. Additionally, \CollectionAssociation\#build\_record\ and \AssociationRelation\#spawn\ are patched to ensure the decoration marker is preserved when building new records or spawning relations.

_lib/active\_decorator/monkey/active\record · high confidence

Decoupling from Rails and adding configuration support

The library now supports usage outside of a Rails environment by making the Rails-specific railtie optional; if the 'rails' gem is not available, the library loads without error. Additionally, a new configuration module is introduced to allow customization of the decorator name suffix, and the core decorator logic is explicitly required.

lib · high confidence

Preserve view context during rescue\_from handling

ActiveDecorator now correctly maintains the view context when exceptions are handled via \rescue\_from\ in Action Controllers. By wrapping the \rescue\_with\_handler\ method, the library ensures that the current view context is pushed onto the stack before the rescue block executes and popped afterwards, allowing decorators to function correctly within error handling paths.

_lib/active\_decorator/monkey/action\controller · high confidence

Test coverage

Added RSpec template for decorator specs; Added controller test for fake detection; Added integration tests for decorator features; Added test fixture Rails application; Added test template for decorators; Added tests for ActiveDecorator association decoration; Added tests for the RSpec Decorator Generator; Migrate test suite from RSpec to Test::Unit.

Dependencies

Updated dependency constraints and gem metadata for modern Ruby/Rails compatibility

The gem now explicitly declares runtime and development dependencies in the Gemfile and gemspec to support a wider range of Ruby and Rails versions. Key changes include adding a runtime dependency on \activesupport\, switching the test framework from RSpec to \test-unit-rails\, and pinning specific versions for \sqlite3\, \puma\, \nokogiri\, \loofah\, and \concurrent-ruby\ based on the Ruby version to ensure compatibility with Ruby 2.x through 4.x and Rails 5 through 8. The gemspec also updates metadata (homepage, license, summary) and excludes test files from the packaged gem.

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

Lenses

  • Code Health 97
  • Architecture 69
  • Maturity 50
  • Readiness 76
  • Security 94

Changes since last survey

  • 300 commits — 286 feature/other, 14 fixes

By area

  • (root) — 108 commits
  • lib/active_decorator — 61 commits
  • .github/workflows — 34 commits
  • (repo) — 31 commits
  • test/fake_app — 18 commits
  • lib/generators — 8 commits
  • test/test_helper.rb — 7 commits
  • test/models — 5 commits
  • gemfiles/Gemfile-rails.5.2.x — 4 commits
  • test/decorator_test.rb — 4 commits
  • gemfiles/Gemfile-rails.5.1.x — 3 commits
  • gemfiles/Gemfile-rails.6.0.x — 3 commits
  • test/features — 3 commits
  • gemfiles/Gemfile-rails.6.1.x — 2 commits
  • .github/dependabot.yml — 1 commit
  • gemfiles/Gemfile-rails.3.2.x — 1 commit
  • gemfiles/Gemfile-rails.4.0.x — 1 commit
  • gemfiles/Gemfile-rails.4.1.x — 1 commit
  • gemfiles/Gemfile-rails.7.0.x — 1 commit
  • gemfiles/Gemfile-rails.edge — 1 commit

Notable commits

  • fix: Fix CI by not symlinking chromedriver
  • fix: Fix README features list indent
  • fix: Fix Ruby 2.7 keyword arguments warning
  • fix: Fix variable name
  • fix: Fix wrong decoration for nested classes
  • fix: Fixed namespace for TestUnit Class
  • fix: Merge pull request #108 from jamesbrooks/fix-nil-decoration
  • fix: Merge pull request #110 from takkanm/fix-gemfile-for-edge
  • fix: Merge pull request #78 from app2641/fix-variable-name
  • fix: Partially revert c215dcc5e6220a6c8ef5b7e804ead7af046b20e7
  • fix: Revert "CI: Use as newest RubyGems as possible"
  • fix: Revert "Rails 7.1 also runs rack 3 and requires to bundle rackup gem now"
  • fix: fix a bug occurs when target specs inherit AC::API
  • fix: fix: return object of ActiveRecord::Relation when it is already decorated
  • change: doesn't exist
  • change: "ArgumentError: unknown driver: :headless_chrome" with Rails 5.1
  • change: "The program 'bundle' is currently not installed." in ruby < 2.3
  • change: "The ubuntu-18.04 environment is deprecated"
  • change: "You must install the rackup gem when using Rack 3 (RuntimeError)"
  • change: "schedule accepts a list of one or more maps with the cron key set"
  • …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

amatsuda/active_decorator 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 1603621b5e29c18d4b3e6818c3b7fd74a3772efc — 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.