trabajo-afectivo/lib/sessions/event.rb
2022-01-01 14:38:12 +01:00

27 lines
756 B
Ruby

# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
class Sessions::Event
include ApplicationLib
def self.run(params)
begin
backend = "Sessions::Event::#{params[:event].to_classname}".constantize
rescue => e
Rails.logger.error e.inspect
Rails.logger.error e.backtrace
return { event: 'error', data: { error: "No such event #{params[:event]}: #{e.inspect}", payload: params[:payload] } }
end
begin
instance = backend.new(params)
result = instance.run
instance.destroy
result
rescue => e
Rails.logger.error e.inspect
Rails.logger.error e.backtrace
{ event: 'error', data: { error: e.message, payload: params[:payload] } }
end
end
end