Service Object Interface

Curated ago by @vaporyhumo

Description

Simple example on how to implement the typical .call interface for plain ruby service objects.

1
2
3
4
5
module ServiceInterface
  def call(...)
    new(...).__send__(:perform)
  end
end

By extending this module you can extract away the creation of the service object, by using .call instead of .new(...).perform.