Skip to content

Release 0.2.0: override-by-default readers, mutable default fix, README and changelog polish#7

Merged
kdonovan merged 14 commits intomainfrom
KD/release-0.2.0
Feb 20, 2026
Merged

Release 0.2.0: override-by-default readers, mutable default fix, README and changelog polish#7
kdonovan merged 14 commits intomainfrom
KD/release-0.2.0

Conversation

@kdonovan
Copy link
Contributor

@kdonovan kdonovan commented Feb 20, 2026

Summary

This PR prepares and documents release 0.2.0 of declarative_initialization.

Behavior changes

  • Override by default: When a method with the same name as an init-arg already exists (on the class or an ancestor), the gem now always defines the reader and overrides that method, so foo consistently returns the init-arg value. Previously it skipped defining the reader and warned; callers had to use @foo. This is a breaking change for code that relied on the old “skip and warn” behavior.
  • Mutable defaults: Default values for Array, Hash, Set, and String are now duplicated per instance when the caller omits that keyword (shallow copy). That prevents accidental cross-instance mutation when using defaults like items: []. Caller-provided values are not duplicated.

Internal / UX

  • Validation and override-warning logic moved into a new DeclarativeInitialization::Internal module (module functions only; no injection into user classes). Override warnings are optional: they run in Rails dev/test or when the logger level is DEBUG. No warning on Rails reload when the method was originally defined by the gem, and no warning when a subclass re-declares an attribute from a parent’s initialize_with.
  • Reader setup now tracks declared readers (including from ancestors) so reload and inheritance cases are handled without spurious warnings.
  • README rewritten for a RubyGems-style, quick-scan flow: what it does, when to use it, install, quick start, usage, and behavior notes (including the mutable-default behavior and how to get private readers).
  • CHANGELOG reorganized with clear Added / Changed / Breaking / Fixed sections for production releases.

@kdonovan kdonovan merged commit c451bc5 into main Feb 20, 2026
1 check passed
@kdonovan kdonovan deleted the KD/release-0.2.0 branch February 20, 2026 00:35
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