Class: EventQ::SerializationProviders::Manager

Inherits:
Object
  • Object
show all
Defined in:
lib/eventq_base/serialization_providers.rb

Instance Method Summary collapse

Constructor Details

#initializeManager

Returns a new instance of Manager.



16
17
18
19
20
21
22
23
24
25
# File 'lib/eventq_base/serialization_providers.rb', line 16

def initialize
  @providers = {}
  if RUBY_PLATFORM =~ /java/
    @providers[OJ_PROVIDER] = EventQ::SerializationProviders::JRuby::OjSerializationProvider
  else
    @providers[OJ_PROVIDER] = EventQ::SerializationProviders::OjSerializationProvider
  end
  @providers[JSON_PROVIDER] = EventQ::SerializationProviders::JsonSerializationProvider
  @providers[BINARY_PROVIDER] = EventQ::SerializationProviders::BinarySerializationProvider
end

Instance Method Details

#get_provider(provider_type) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/eventq_base/serialization_providers.rb', line 27

def get_provider(provider_type)
  provider = @providers[provider_type]
  if provider.nil?
    raise "Invalid provider type specified: #{provider_type}"
  end
  return provider.new
end