class MessengerPigeon::EndpointManager
Create and manage instances of Sources or Destinations
Attributes
instances[R]
Public Class Methods
new(direction)
click to toggle source
# File lib/messenger_pigeon/endpoint_manager.rb, line 6 def initialize(direction) @instances = {} @direction = direction.to_s.capitalize end
Public Instance Methods
direction()
click to toggle source
# File lib/messenger_pigeon/endpoint_manager.rb, line 17 def direction @direction.downcase.to_sym end
finalise()
click to toggle source
# File lib/messenger_pigeon/endpoint_manager.rb, line 21 def finalise @instances.values.each(&:complete) @instances = {} end
prepare(name, endpoint_defn)
click to toggle source
# File lib/messenger_pigeon/endpoint_manager.rb, line 11 def prepare(name, endpoint_defn) fail 'Endpoint definition not defined' unless endpoint_defn.class == Hash type = endpoint_defn[:type] || fail('Endpoint type not set') @instances[name] || build_instance(name, type, endpoint_defn[:options]) end
Private Instance Methods
build_instance(name, type, options)
click to toggle source
# File lib/messenger_pigeon/endpoint_manager.rb, line 28 def build_instance(name, type, options) o = Kernel.const_get("MessengerPigeon").const_get("#{type}").const_get("#{@direction}") @instances[name] = o.new(options) end