trabajo-afectivo/lib/sessions/event.rb

19 lines
431 B
Ruby
Raw Normal View History

2015-11-10 14:01:04 +00:00
class Sessions::Event
include ApplicationLib
def self.run(event, data, session, client_id)
2015-11-10 14:05:29 +00:00
adapter = "Sessions::Event::#{event.to_classname}"
begin
backend = load_adapter(adapter)
rescue => e
return { error: "No such event #{event}" }
end
2015-11-10 14:01:04 +00:00
2015-11-10 14:05:29 +00:00
ActiveRecord::Base.establish_connection
result = backend.run(data, session, client_id)
ActiveRecord::Base.remove_connection
result
2015-11-10 14:01:04 +00:00
end
2015-11-10 14:05:29 +00:00
end