module Ni::Main::ModuleMethods

Public Instance Methods

register_unique_interactor(id, interactor_klass) click to toggle source
# File lib/ni/main.rb, line 10
def register_unique_interactor(id, interactor_klass)
  @unique_ids_map ||= {}

  # ruby has a strange behaviour here while comparing classes.
  # Think it's an Rails autoload issue, but should compare the class names
  if @unique_ids_map[id].present? 
    if interactor_klass.name.present? && @unique_ids_map[id].name != interactor_klass.name
      raise "Try to register new interactor with the existing ID: #{id}"        
    end  
  end
  
  @unique_ids_map[id] = interactor_klass
end