Class: Channelizer::Factory

Inherits:
Object
  • Object
show all
Includes:
Exceptions
Defined in:
lib/channelizer/factory.rb

Class Method Summary collapse

Class Method Details

.build_channel(type, options) ⇒ Object



12
13
14
15
# File 'lib/channelizer/factory.rb', line 12

def build_channel(type,options)
  raise InvalidChannelTypeError, ":#{type} is not a registered channel" unless @registered_channels[type.to_sym]
  @registered_channels[type.to_sym].new(options)
end

.channelsObject



17
18
19
# File 'lib/channelizer/factory.rb', line 17

def channels
  @registered_channels ||= {}
end

.register(name, klass) ⇒ Object



7
8
9
10
# File 'lib/channelizer/factory.rb', line 7

def register(name,klass)
  @registered_channels ||= {}
  @registered_channels[name.to_sym] = klass
end