Today Icelab Learned

Using for dynamically adding class methods

Say you’re building a system where you want to dynamically add some class methods to a class at a particular moment, but without leaving them around for use on the class at other times.

This is pretty easy if you create an anonymous subclass whenever you need to use the special class methods:

module MyCustomFinders
  def special_finder
    where(something: "is special")

class MyThing < ActiveRecord::Base