class Hyalite::EventPluginRegistry

Public Class Methods

new(*plugins) click to toggle source
# File lib/hyalite/event_plugin/event_plugin_registry.rb, line 3
def initialize(*plugins)
  @registration_name_modules = {}
  @registration_name_dependencies = {}
  @plugins = []
  plugins.each {|plugin| add_plugin(plugin) }
end

Public Instance Methods

[](registration_name) click to toggle source
# File lib/hyalite/event_plugin/event_plugin_registry.rb, line 28
def [](registration_name)
  @registration_name_modules[registration_name]
end
add_plugin(plugin) click to toggle source
# File lib/hyalite/event_plugin/event_plugin_registry.rb, line 10
def add_plugin(plugin)
  plugin.event_types.each do |key, dispatch_config|
    dispatch_config[:phasedRegistrationNames].each do |phase, registration_name|
      @registration_name_modules[registration_name] = plugin
      @registration_name_dependencies[registration_name] = dispatch_config[:dependencies]
    end
  end
  @plugins << plugin
end
dependencies(registration_name) click to toggle source
# File lib/hyalite/event_plugin/event_plugin_registry.rb, line 24
def dependencies(registration_name)
  @registration_name_dependencies[registration_name]
end
extract_events(top_level_type, top_level_target, top_level_target_id, event) click to toggle source
# File lib/hyalite/event_plugin/event_plugin_registry.rb, line 32
def extract_events(top_level_type, top_level_target, top_level_target_id, event)
  @plugins.each.with_object([]) do |plugin, events|
    synthetic_event = plugin.extract_event(top_level_type, top_level_target, top_level_target_id, event)
    events << synthetic_event if synthetic_event
  end
end
include?(registration_name) click to toggle source
# File lib/hyalite/event_plugin/event_plugin_registry.rb, line 20
def include?(registration_name)
  @registration_name_modules.has_key? registration_name
end
registration_names() click to toggle source
# File lib/hyalite/event_plugin/event_plugin_registry.rb, line 39
def registration_names
  @registrasion_names ||= Set.new.tap do |names|
    TOP_LEVEL_EVENTS_TO_DISPATCH_CONFIG.each_value do |value|
      value[:phasedRegistrationNames].each_value do |name|
        names << name
      end
    end
  end
end