Class: ActiveDomain::CommandRoutes

Inherits:
Object
  • Object
show all
Defined in:
lib/active_domain/command_routes.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCommandRoutes

Returns a new instance of CommandRoutes.



9
10
11
# File 'lib/active_domain/command_routes.rb', line 9

def initialize
  self.processors = {}
end

Class Method Details

.route(type, processor, method) ⇒ Object



23
24
25
# File 'lib/active_domain/command_routes.rb', line 23

def self.route(type, processor, method)
  @@routes[type] = [processor, method]
end

Instance Method Details

#run_command(command) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/active_domain/command_routes.rb', line 13

def run_command(command)
  RELOADER.execute_if_updated
  processor, method = @@routes[command.class]
  processor_instance(processor).method(method).call(command)
rescue Exception => e
  LOGGER.error e.message
  LOGGER.error e.backtrace.join("\n")
  raise ActiveEvent::DomainExceptionCapture, ["#{e.class.name}: #{e.message}", e.backtrace].to_json, e.backtrace
end

#versionObject



5
6
7
# File 'lib/active_domain/command_routes.rb', line 5

def version
  '0.1.0'
end