Sha256: 97f5e95d72e121f3b585483d950f54492bc8a37fab21c54ee91e3697c773022c

Contents?: true

Size: 950 Bytes

Versions: 2

Compression:

Stored size: 950 Bytes

Contents

class FluQ::Feed < Celluloid::SupervisionGroup

  # @attr_reader [String] name
  attr_reader :name

  # @attr_reader [Array] handlers
  attr_reader :handlers

  # Constructor
  # @param [String] name feed name
  def initialize(name, &block)
    @name     = name.to_s
    @handlers = []
    super(&block)
  end

  # @return [Array<FluQ::Input::Base>] inputs
  def inputs
    actors
  end

  # Listens to an input
  # @param [Class<FluQ::Input::Base>] klass input class
  # @param [multiple] args initialization arguments
  def listen(klass, *args)
    supervise klass, name, handlers, *args
  end

  # Registers a handler
  # @param [Class<FluQ::Handler::Base>] klass handler class
  # @param [multiple] args initialization arguments
  def register(klass, *args)
    handlers.push [klass, *args]
  end

  # @return [String] introspection
  def inspect
    "#<#{self.class.name}(#{name}) inputs: #{inputs.size}, handlers: #{handlers.size}>"
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fluq-0.8.1 lib/fluq/feed.rb
fluq-0.8.0 lib/fluq/feed.rb