Designing A Great Ruby API
summary
Rails adds an attributes API that extracts typecasting out of ad‑hoc attribute reader/writer overrides into explicit type objects and an AttributeSet, letting models declare or lazily override attribute types without hacking columns. The implementation composes decorators (used for serialize and time zone conversion), fixes mutation detection so dirty tracking behaves correctly, and makes concrete guarantees (save/reload and assigning the same value don’t flip changed state). Most legacy hacks are removed and the API ships in Rails 5.
AI-written summary · about
chapters (16)
- 0:00Introduction and speaker intro
- 1:02Identifying the problem to solve
- 3:56Problems with current attribute overrides
- 11:21Defining typecasting and type coercion
- 15:46Starting the API design process
- 17:57Introducing the type object
- 21:06Writing tests for the new API
- 23:57Avoiding DSL complexity
- 26:24Lazy vs strict API representations
- 29:17Decorators and type modification
- 32:11Simplifying serialize with the new API
- 33:38Making the API universal
- 35:48Performance considerations in API design
- 36:55Composition over inheritance
- 37:59Establishing API contracts
- 39:25Conclusion and Q&A
related talks
38mDesigning a Great Ruby API - How We're Simplifying Rails 5
45mThe illusion of stable APIs
35mBuilding Ambitious APIs with Ruby
41mAPPLICATION ARCHITECTURE: BOUNDARIES, OBJECT ROLES, & PATTERNS
32mFast, Testable and SANE APIs
26mMeta-programming for Dummies
45mToward a Design for Ruby
38mRails on Ruby: How Ruby Makes Rails Great
