pawurb/smart_init: A simple gem for eliminating Ruby initializers boilerplate code, and providing unified service objects API

12-Jun-2025 21
This gem provides a simple DSL for getting rid of it. It offers an alternative to using Struct.new which does not check for number of parameters provided in initializer, exposes getters and instantiates unecessary class instances. Smart Init offers a unified API convention for stateless service objects, accepting values in initializer and exposing one public class method call which instantiates new objects and accepts arguments passed to initializer. Check out this blog post for my reasoning behind this approach to service object pattern.
Use coupon code:

RUBYONRAILS

to get 30% discount on our bundle!
Prepare for your next tech interview with our comprehensive collection of programming interview guides. Covering JavaScript, Ruby on Rails, React, and Python, these highly-rated books offer thousands of essential questions and answers to boost your interview success. Buy our 'Ultimate Job Interview Preparation eBook Bundle' featuring 2200+ questions across multiple languages. Ultimate Job Interview Preparation eBook Bundle