The Ruby Module Builder Pattern
summary
Shows how to turn Module into a configurable template: subclass Module and use an initializer that defines methods so each included instance carries its own configuration and closures for encapsulation. Replaces brittle bootstrap/anonymous-module patterns used in device/rails with fewer lines and predictable super chains. Applied to the Mobility translation gem to support multiple storage back ends from one interface, echoed by similar refactors in Alchemist and dry-equalizer, and the blog post drew ~30–40k views.
AI-written summary · about
chapters (8)
- 0:00Introduction to modularity
- 2:16Modular design principles
- 6:00Ruby module limitations
- 10:46Evolution of module patterns
- 20:06The module builder pattern
- 25:51Practical implementation
- 30:43Reflection and conclusion
- 33:29Q&A and closing
related talks
35mModularizing Rails Monoliths One Bite at a Time
46mRails as a piece of birthday cake
17mDesigning software that maximizes developer productivity
40mTrailblazer: A new Architecture for Rails
36mA custom design pattern for building dynamic ActiveRecord queries
31mWhat Comes After MVC
53mRuby 2 in Ruby on Rails
01h 03mStrengthening the Ruby Ecosystem Part II: Merb
