Re:Friendly Attributes Pattern in Ruby
by drzel on Saturday November 08, 2025 @09:48AM
(#45856974)
[ Parent
| on HN ]
I think this is the pattern I would reach for as well, separating the data from the execution. Being declarative about the plans (either with a config file, db backend, or simply a PORO) allows the plans themselves to be agnostic to how they are used and leaves you room to write a clean API for their creation without mixing in their definition.
Also ActiveSupport has Object#with_options which has a similar intent, but I rarely ever see it used in codebases.
Re:Friendly Attributes Pattern in Ruby
by Footkerchief on Saturday November 08, 2025 @04:34PM
(#45860250)
Exactly. Use a fancy expressive structure if you want, but don't try to abstract away the mapping between that and the general-purpose code that it relies on. "Each domain has its own rules"? How would I even know where to look for those?