Skip to content

fix: cast also when building the attribute from the default#59

Open
HoneyryderChuck wants to merge 2 commits into
palkan:masterfrom
persona-id:cast-defaults
Open

fix: cast also when building the attribute from the default#59
HoneyryderChuck wants to merge 2 commits into
palkan:masterfrom
persona-id:cast-defaults

Conversation

@HoneyryderChuck
Copy link
Copy Markdown

What is the purpose of this pull request?

this enforces coercing in cases where the default is set up in a related-but-not-the-same type defined for the attribute.

this is required to work correctly which gems which extend on the activemodel attributes API, such as store_model, where the default is recommended to be defined as a hash for cases where the attribute type is defined as a nested store model type.

What changes did you make? (overview)

The change is simply to apply the same type.cast operation on the default value, same as when the value is set.

Is there anything you'd like reviewers to focus on?

While the patch wasn't AI-generated, the tests were. They may be "overtesting", so perhaps I'd focus on "filler" tests which don't add much and could be removed.

Checklist

  • I've added tests for this change
  • I've added a Changelog entry
  • I've updated a documentation (Readme)

@HoneyryderChuck HoneyryderChuck force-pushed the cast-defaults branch 3 times, most recently from 6580bae to 38b7ee1 Compare May 18, 2026 11:51
this enforces coercing in cases where the default is set up in a
related-but-not-the-same type defined for the attribute.

this is required to work correctly which gems which extend on the
activemodel attributes API, such as `store_model`, where the default is
recommended to be defined as a hash for cases where the attribute type
is defined as a nested store model type.
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