Class: EventRouter::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/event_router/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



10
11
12
13
14
15
16
17
18
19
# File 'lib/event_router/configuration.rb', line 10

def initialize
  @delivery_adapters    = {}
  @serializer_adapters  = {}

  register_delivery_adapter(:sync)
  @delivery_adapter = :sync

  register_serializer_adapter(:json)
  @serializer_adapter = :json
end

Instance Attribute Details

#delivery_adapterObject

Returns the value of attribute delivery_adapter.



7
8
9
# File 'lib/event_router/configuration.rb', line 7

def delivery_adapter
  @delivery_adapter
end

#delivery_adaptersObject (readonly)

Returns the value of attribute delivery_adapters.



7
8
9
# File 'lib/event_router/configuration.rb', line 7

def delivery_adapters
  @delivery_adapters
end

#serializer_adapterObject

Returns the value of attribute serializer_adapter.



7
8
9
# File 'lib/event_router/configuration.rb', line 7

def serializer_adapter
  @serializer_adapter
end

#serializer_adaptersObject (readonly)

Returns the value of attribute serializer_adapters.



7
8
9
# File 'lib/event_router/configuration.rb', line 7

def serializer_adapters
  @serializer_adapters
end

Instance Method Details

#delivery_adapter_class(adapter) ⇒ Object



27
28
29
# File 'lib/event_router/configuration.rb', line 27

def delivery_adapter_class(adapter)
  @delivery_adapters[adapter]
end

#register_delivery_adapter(adapter, opts = {}) ⇒ Object



31
32
33
34
35
36
# File 'lib/event_router/configuration.rb', line 31

def register_delivery_adapter(adapter, opts = {})
  adapter_class = load_adapter_class(Publisher::ADAPTERS, adapter) || opts[:adapter_class]

  adapter_class.options       = opts
  @delivery_adapters[adapter] = adapter_class
end

#register_serializer_adapter(adapter, opts = {}) ⇒ Object



48
49
50
51
52
# File 'lib/event_router/configuration.rb', line 48

def register_serializer_adapter(adapter, opts = {})
  adapter_class = load_adapter_class(Serializer::ADAPTERS, adapter) || opts[:adapter_class]

  @serializer_adapters[adapter] = adapter_class
end

#serializer_adapter_class(adapter) ⇒ Object



44
45
46
# File 'lib/event_router/configuration.rb', line 44

def serializer_adapter_class(adapter)
  @serializer_adapters[adapter]
end