Skip to content

Fix frozen model can still be modified#212

Open
cgriego wants to merge 5 commits intomasterfrom
claude/fix-frozen-model-afXe4
Open

Fix frozen model can still be modified#212
cgriego wants to merge 5 commits intomasterfrom
claude/fix-frozen-model-afXe4

Conversation

@cgriego
Copy link
Owner

@cgriego cgriego commented Feb 28, 2026

Override #freeze in Attributes to initialize and freeze @attributes,
ensuring that any attempt to write to a frozen model naturally raises
FrozenError (RuntimeError on Ruby < 2.5) via the frozen Hash.

Add frozen_error_class test helper in spec/support for Ruby version
compatibility. Write tests covering write_attribute, []=, reads,
inspect, apply_defaults (unit), and assign_attributes/attributes=
across the MassAssignment + Attributes boundary (functional).

https://claude.ai/code/session_01MPZp1QECyJ3vnRxgStE1p8

Override #freeze in Attributes to initialize and freeze @attributes,
ensuring that any attempt to write to a frozen model naturally raises
FrozenError (RuntimeError on Ruby < 2.5) via the frozen Hash.

Add frozen_error_class test helper in spec/support for Ruby version
compatibility. Write tests covering write_attribute, []=, reads,
inspect, apply_defaults (unit), and assign_attributes/attributes=
across the MassAssignment + Attributes boundary (functional).

https://claude.ai/code/session_01MPZp1QECyJ3vnRxgStE1p8
- Define frozen_error_class in FrozenErrorHelper module, configured
  via RSpec config.include rather than as a bare Kernel method
- Move generated attribute setter frozen test to attributes_spec.rb
  where it belongs (Attributes defines the method)
- Remove Attributes method tests from MassAssignment functional spec;
  MassAssignment frozen context now only tests assign_attributes and
  attributes=

https://claude.ai/code/session_01MPZp1QECyJ3vnRxgStE1p8
Copy link
Owner Author

@cgriego cgriego left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@claude

  1. Make the next version 0.18 since behavior changes
  2. Update the CHANGELOG but the release date is Unreleased
  3. The freeze method should be undocumented since it's built-in

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.

2 participants