Mirosław Pragłowski bio photo

Mirosław Pragłowski

Email Twitter Github
Facebook LinkedIn Instagram

… somewhere in application.rb configuration

… somewhere in application.rb configuration

config.to_prepare do Rails.configuration.event_store = RailsEventStore.new.tap do |res| #… explicit setup preffered res.subscribe(AccessControl::Registration.new, to: [Ticketing::TicketGenerated]) end Rails.configuration.command_bus = Arkency::CommandBus.new.tap do |bus| bus.register(AccessControl::Scan, -> (cmd) { AccessControl::Service.new.scan(cmd) }) end end

class SomeController def some_controller_action_you_name_it scan_request = params.slice(:barcode, :event_id, :terminal) cmd = AccessControl::Scan.new(scan_request) Rails.configuration.command_bus.(cmd) # note: RoR ends here head :ok rescue AccessControl::Entry::NoEntrance head :not_found end end