Skip to content

0.2.2 - dynamic storage resolution#8

Merged
bnlucas merged 1 commit intomainfrom
0.2.2
May 4, 2025
Merged

0.2.2 - dynamic storage resolution#8
bnlucas merged 1 commit intomainfrom
0.2.2

Conversation

@bnlucas
Copy link
Owner

@bnlucas bnlucas commented May 4, 2025

No breaking changes – the public DSL (cattri, final_cattri) remains identical to v0.2.0.

Removed

  • Removed Cattri::AttributeRegistry#copy_attributes_to and all associated logic. Subclass attribute propagation
    is now handled entirely via runtime resolution in Context#storage_receiver_for, eliminating the need for eager
    copying of attribute values or metadata.
  • Removed Cattri::Inheritance and its use of .inherited hooks for subclass propagation, since all relevant state
    is now derived dynamically.

Changed

  • Replaced static subclass propagation with dynamic storage resolution using Context#storage_receiver_for,
    which now determines the correct backing object (instance, class, or singleton class) for all reads and writes.
  • AttributeCompiler.define_accessor now uses storage_receiver_for to set final class-level attribute values
    during compilation.
  • Final class-level attributes (final: true, scope: :class) are now evaluated and written directly to the correct
    storage receiver without relying on prior duplication logic.

Added

  • Proper support for defining attributes directly on a module’s singleton_class, ensuring values are stored and
    accessed consistently across runtime and functional tests.
    module MyModule
      class << self
        include Cattri
    
        cattri :version, "0.1.0", final: true, scope: :class
      end
    end
  • Regression tests ensuring:
    • Subclass attribute shadowing works for final: true, scope: :class.
    • Instance and class attribute isolation behaves as expected across inheritance chains.
    • No mutation of final attributes once defined.
  • Test coverage for Context#storage_receiver for and Context#resolve_class_storage_for across all branching logic.

@codecov
Copy link

codecov bot commented May 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (7f535bd) to head (0c55ea4).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main        #8   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           15        14    -1     
  Lines          364       374   +10     
  Branches        49        56    +7     
=========================================
+ Hits           364       374   +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bnlucas bnlucas merged commit 13e6755 into main May 4, 2025
4 checks passed
@bnlucas bnlucas deleted the 0.2.2 branch May 4, 2025 17:20
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