Sha256: 868332bcd8d90ab93f85241de4a1e74d49c8cff04657e8c5f9cc4045465c86fe
Contents?: true
Size: 859 Bytes
Versions: 5
Compression:
Stored size: 859 Bytes
Contents
# frozen_string_literal: true require "active_support" require "active_support/core_ext" module TrackBallast # A module for building callable service classes where exactly one method # will ever be called and only the return value of that method matters, not # the class instance itself. # # == Usage # # - Define +initialize+ with the desired arguments # - Define +call+ with the desired logic # - Extend the class with this module # # == Example # # class DivideByTwo # extend TrackBallast::Callable # # def initialize(int) # @int = int # end # # def call # int / 2 # end # # private # # attr_reader :int # end # # DivideByTwo.call(10) # => 5 module Callable def call(...) new(...).call { yield } end end end
Version data entries
5 entries across 5 versions & 1 rubygems