Use Thread.current instead of a class_attribute for thread safety

class_attribute is not thread safe _by design_ (https://github.com/rails/rails/issues/14021). This commit enables storing the pusherable trigger state in the Thread.current hash for thread safety.

I also took the liberty to do a bit of refactoring.