Sha256: aef363a52e7f1d9400cd84c008e702345c844d9c5d7613493317a7c6abf7dadc

Contents?: true

Size: 874 Bytes

Versions: 10

Compression:

Stored size: 874 Bytes

Contents

# frozen_string_literal: true

require_relative '../base.rb'

module Fusuma
  module Plugin
    module Buffers
      # buffer events and output
      class Buffer < Base
        def initialize(*args)
          @events = Array.new(*args)
        end

        attr_reader :events

        # @return [String]
        def type
          self.class.name.underscore.split('/').last.gsub('_buffer', '')
        end

        # @param event [Event]
        def buffer(event)
          return if event&.tag != source

          @events.push(event)
        end

        # clear buffer
        def clear
          @events.clear
        end

        # Set source for tag from config.yml.
        # DEFAULT_SOURCE is defined in each plugins.
        def source
          @source ||= config_params(:source) || self.class.const_get('DEFAULT_SOURCE')
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
fusuma-1.4.1 lib/fusuma/plugin/buffers/buffer.rb
fusuma-1.4.0 lib/fusuma/plugin/buffers/buffer.rb
fusuma-1.3.3 lib/fusuma/plugin/buffers/buffer.rb
fusuma-1.3.2 lib/fusuma/plugin/buffers/buffer.rb
fusuma-1.3.1 lib/fusuma/plugin/buffers/buffer.rb
fusuma-1.3.0 lib/fusuma/plugin/buffers/buffer.rb
fusuma-1.2.1 lib/fusuma/plugin/buffers/buffer.rb
fusuma-1.2 lib/fusuma/plugin/buffers/buffer.rb
fusuma-1.1 lib/fusuma/plugin/buffers/buffer.rb
fusuma-1.0 lib/fusuma/plugin/buffers/buffer.rb