Module: Ni::Main::ModuleMethods

Included in:
Ni::Main
Defined in:
lib/ni/main.rb

Instance Method Summary collapse

Instance Method Details

#register_unique_interactor(id, interactor_klass) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# 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