module RedmineEventOutbox
  module Patches
    module ContactPatch
      def self.included(base)
        base.class_eval do
          after_commit :record_event_outbox_contact_created, :on => :create
          after_commit :record_event_outbox_contact_updated, :on => :update
        end
      end

      private

      def record_event_outbox_contact_created
        RedmineEventOutbox::Event.record_contact_created(self, User.current)
      end

      def record_event_outbox_contact_updated
        RedmineEventOutbox::Event.record_contact_updated(self, User.current)
      end
    end
  end
end
