Meditations on a Class Method

def self.run(user)
  new(user).run
end

I have read a thoughtbot’s blog post today Meditations on a Class Method

I feel I like this style because it helps me simplify caller interface, so we could stub/mock it easier. What is your opinion on class methods like this?

Yeah, I’ve been doing this for a while, I don’t remember where I originally picked it up. It’s especially useful in tests so that you don’t need to have a mock returning another mock, (or stub_chain in RSpec).

1 Like