Class: LogStash::OutputDelegatorStrategyRegistry

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/output_delegator_strategy_registry.rb

Defined Under Namespace

Classes: InvalidStrategyError

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeOutputDelegatorStrategyRegistry

Returns a new instance of OutputDelegatorStrategyRegistry.



10
11
12
# File 'lib/logstash/output_delegator_strategy_registry.rb', line 10

def initialize()
  @map = {}
end

Class Method Details

.instanceObject

This is generally used as a singleton Except perhaps during testing



6
7
8
# File 'lib/logstash/output_delegator_strategy_registry.rb', line 6

def self.instance
  @instance ||= self.new
end

Instance Method Details

#class_for(type) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/logstash/output_delegator_strategy_registry.rb', line 22

def class_for(type)
  klass = @map[type]

  if !klass
    raise InvalidStrategyError, "Could not find output delegator strategy of type '#{type}'. Valid strategies: #{@strategy_registry.types}"
  end

  klass
end

#classesObject



14
15
16
# File 'lib/logstash/output_delegator_strategy_registry.rb', line 14

def classes
  @map.values
end

#register(type, klass) ⇒ Object



32
33
34
# File 'lib/logstash/output_delegator_strategy_registry.rb', line 32

def register(type, klass)
  @map[type] = klass
end

#typesObject



18
19
20
# File 'lib/logstash/output_delegator_strategy_registry.rb', line 18

def types
  @map.keys
end