Sha256: 6a8e38664ec55de99fd241994b066d221b5b5c309821a193c9d8de817f82bd80

Contents?: true

Size: 1.12 KB

Versions: 22

Compression:

Stored size: 1.12 KB

Contents

require 'bbk/utils/proxy_logger'

module BBK
  module App
    module Processors
      class Base

        attr_reader :logger

        def initialize(*untyped, logger: BBK::App.logger, **)
          logger = logger.respond_to?(:tagged) ? logger : ActiveSupport::TaggedLogging.new(logger)
          @logger = BBK::Utils::ProxyLogger.new(logger, tags: self.class.to_s)
        end

        def rule
          unless self.class.respond_to?(:rule)
            raise NotImplementedError.new("Not implemented class method rule in #{self.class.name}")
          end

          self.class.rule
        end

        def call(message, results: [])
          debug 'processing message...'

          process(message, results: results)

          results
        end

        def process(_message, results: [])
          raise NotImplementedError.new("process method abstract in Processor class. Results count: #{results.count}")
        end


        %i[debug info warn error fatal unknown].each do |severity|
          define_method(severity) do |*args|
            logger.public_send(severity, *args)
          end
        end

      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
bbk-app-1.1.1.273627 lib/bbk/app/processors/base.rb
bbk-app-1.1.1.273338 lib/bbk/app/processors/base.rb
bbk-app-1.1.1.273312 lib/bbk/app/processors/base.rb
bbk-app-1.1.1.273294 lib/bbk/app/processors/base.rb
bbk-app-1.1.0.219406 lib/bbk/app/processors/base.rb
bbk-app-1.1.0.216998 lib/bbk/app/processors/base.rb
bbk-app-1.1.0.204569 lib/bbk/app/processors/base.rb
bbk-app-1.1.0.200751 lib/bbk/app/processors/base.rb
bbk-app-1.1.0.200186 lib/bbk/app/processors/base.rb
bbk-app-1.1.0.199675 lib/bbk/app/processors/base.rb
bbk-app-1.1.0.199604 lib/bbk/app/processors/base.rb
bbk-app-1.1.0.199389 lib/bbk/app/processors/base.rb
bbk-app-1.1.0.199383 lib/bbk/app/processors/base.rb
bbk-app-1.0.0.152254 lib/bbk/app/processors/base.rb
bbk-app-1.0.0.141716 lib/bbk/app/processors/base.rb
bbk-app-1.0.0.80957 lib/bbk/app/processors/base.rb
bbk-app-1.0.0.79514 lib/bbk/app/processors/base.rb
bbk-app-1.0.0.79241 lib/bbk/app/processors/base.rb
bbk-app-1.0.0.78020 lib/bbk/app/processors/base.rb
bbk-app-1.0.0.72920 lib/bbk/app/processors/base.rb