Sha256: 44c703e66203fdbef5d58ae0a4e92e545fb8dfdf12dd2eae91231a999bf917a1
Contents?: true
Size: 825 Bytes
Versions: 14
Compression:
Stored size: 825 Bytes
Contents
# frozen-string-literal: true using Rodbot::Refinements module Rodbot # Foundation to run app, relay and schedule services class Services extend Forwardable def_delegator :@dispatcher, :run, :run def_delegator :@dispatcher, :interrupt, :interrupt def initialize @dispatcher = Rodbot::Dispatcher.new('rodbot') end def exist?(service) Rodbot::SERVICES.include? service.to_sym end def register(service, extension: nil) fail(Rodbot::ServiceError, "unknown service #{service}") unless exist? service tasks = "rodbot/services/#{service}".constantize.new.tasks(only: extension) tasks.each_with_index do |task, index| name = [service, (index if tasks.count > 1)].compact.join('-') @dispatcher.register(name, &task) end end end end
Version data entries
14 entries across 14 versions & 1 rubygems