def run_callbacks(kind, user, session, *args) # args - |user, session, opts|
      # Last callback arg MUST be a Hash
      options = args.last
      send("#{kind}_callbacks").each do |callback, conditions| # each callback has 'conditions' stored with it
        conditions = conditions.dup.delete_if { |key, _val| !@conditions.include? key }
        invalid = conditions.find do |key, value|
          value.is_a?(Array) ? !value.include?(options[key]) : (value != options[key])
        end
        callback.call(user, session, *args) unless invalid
      end
      nil
    end
def run_callbacks(kind, user, session, *args) # args - |user, session, opts|
      # Last callback arg MUST be a Hash
      options = args.last
      send("#{kind}_callbacks").each do |callback, conditions| # each callback has 'conditions' stored with it
        conditions = conditions.dup.delete_if { |key, _val| !@conditions.include? key }
        invalid = conditions.find do |key, value|
          value.is_a?(Array) ? !value.include?(options[key]) : (value != options[key])
        end
        callback.call(user, session, *args) unless invalid
      end
      nil
    end
Run callbacks of the given kind.

 * kind - :authenticate or :after_set_user
 * args - user, session, opts hash. Opts is an optional event, e.g. { event: :authentication }

 Example:
   Authenticate.lifecycle.run_callbacks(:after_set_user, @current_user, self, { event: :authentication })