# HG changeset patch
# User Katia Saurfelt <katia.saurfelt@logilab.fr>
# Date 1495532677 -7200
#      Tue May 23 11:44:37 2017 +0200
# Node ID de231ccbbcf3c976002f45fea1341a20c5a6f5eb
# Parent  7859ebfada15e37e77404b2efbe4f10283815944
[refactoring] split IFullTextIndexSerializable.serialize method to ease overriding

diff --git a/cubicweb_elasticsearch/entities.py b/cubicweb_elasticsearch/entities.py
--- a/cubicweb_elasticsearch/entities.py
+++ b/cubicweb_elasticsearch/entities.py
@@ -109,6 +109,12 @@
         attrs.extend(self.custom_indexable_attributes)
         return attrs
 
+    def process_attributes(self):
+        data = {}
+        for attr in self.fulltext_indexable_attributes:
+            data[attr] = getattr(self.entity, attr)
+        return data
+
     def serialize(self, complete=True):
         entity = self.entity
         if complete:
@@ -118,9 +124,8 @@
             'eid': entity.eid,
             'cwuri': entity.cwuri,
         }
-        for attr in self.fulltext_indexable_attributes:
-            data[attr] = getattr(entity, attr)
         # TODO take a look at what's in entity.cw_relation_cache
+        data.update(self.process_attributes())
         return data