event.rb 686 B

12345678910111213141516171819202122232425
  1. class Sessions::Event
  2. include ApplicationLib
  3. def self.run(params)
  4. begin
  5. backend = "Sessions::Event::#{params[:event].to_classname}".constantize
  6. rescue => e
  7. Rails.logger.error e.inspect
  8. Rails.logger.error e.backtrace
  9. return { event: 'error', data: { error: "No such event #{params[:event]}: #{e.inspect}", payload: params[:payload] } }
  10. end
  11. begin
  12. instance = backend.new(params)
  13. result = instance.run
  14. instance.destroy
  15. result
  16. rescue => e
  17. Rails.logger.error e.inspect
  18. Rails.logger.error e.backtrace
  19. return { event: 'error', data: { error: e.message, payload: params[:payload] } }
  20. end
  21. end
  22. end