Building Extractable Libraries in Rails
summary
Practical conventions: treat /lib as a temple — make every lib component extractable into a gem by namespacing and explicit requires; avoid autoloading everything in /lib by wiring requires from an initializer; use configuration to hide credentials via a module-level configuration object so keys live in initializers not constants; isolate domain objects with DCI (roles + contexts) to keep business logic off models. Examples: BMI → tweet pipeline uses Struct/OpenStruct for doubles, background queue for delivery, and is used at Iowa Health; DCI works well for create/update/destroy but not for index views.
AI-written summary · about
chapters (37)
- 0:00Introduction
- 2:04Beautiful Language
- 2:17Sense of Love Changes
- 2:50Rails conventions
- 3:08Freedom from tedious decisions
- 3:25Productivity
- 3:57Why is this important
- 4:23Conventions
- 4:56Game Spacing
- 5:22Autoload Trap
- 5:33Separating Mesh
- 6:10Namespace
- 6:28Murph typing
- 7:08Smurf module
- 7:34Avoid autoload trap
- 8:23Initializers Directory
- 9:28Hide your credentials
- 10:09Entry point
- 10:33Implementation
- 11:57Focus
- 13:28Concerns
- 14:16DCI
- 15:08Role
- 16:31Fake class
- 16:51Openstruct
- 17:28Mock
- 18:02Testing
- 18:36Context
- 20:07Unit Testing
- 21:18Beam
- 22:19Queue
- 22:43Rescue Job
- 23:12Twitter Message
- 25:02Twitter
- 25:21Treat your lib directly
- 26:10Avoid configuration nightmares
- 26:28Protect domain interactions
related talks
26mDissecting Rails - a different approach to learning Rails
38mAll you need is Rails (Engines): Compartmentalising your Monolith
33mMICRO LIBRARIES FTW
40mMonoliths Between Microservices
50mLiving Social Lightning Talks
35mWrangling Large Rails Codebases
01h 28mGet started with Component-based Rails applications!
22mNitty Gritty Service Building
