def apply_events(events)
      events.each do |event|
        method_name = event_handler(event)
        public_send(method_name, event.data) if respond_to?(method_name)
      end
      @revision = events.last&.revision.to_i if events.last.respond_to?(:revision)
    end
def apply_events(events)
      events.each do |event|
        method_name = event_handler(event)
        public_send(method_name, event.data) if respond_to?(method_name)
      end
      @revision = events.last&.revision.to_i if events.last.respond_to?(:revision)
    end
Replay events, building up the state of the aggregate.
 Used by Repository.