event.rb 553 B

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