# frozen_string_literal: true module Lite module Service class Base class << self def call(*args) klass = new(*args) klass.call klass end def run(*args) klass = new(*args) klass.call end end attr_reader :result def initialize(*args) @args = args end def call raise Lite::Service::NotImplementedError unless defined?(command) return @result if called? @called = true @result = command end def called? @called ||= false end def recall! @called = false %i[cache errors].each { |mixin| send(mixin).clear if respond_to?(mixin) } call end end end end