From d94a1a94d6eec34eda966fc146966c728fc7cff9 Mon Sep 17 00:00:00 2001 From: Mauricio Giacomini Girardello <mgg12@inf.ufpr.br> Date: Tue, 12 Jan 2016 11:27:06 -0200 Subject: [PATCH] refactoring orient_db_serializable module --- app/models/concerns/orient_db_serializable.rb | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/app/models/concerns/orient_db_serializable.rb b/app/models/concerns/orient_db_serializable.rb index 4d0daeeca..2c4e3591a 100644 --- a/app/models/concerns/orient_db_serializable.rb +++ b/app/models/concerns/orient_db_serializable.rb @@ -8,18 +8,23 @@ module OrientDbSerializable var_name = sanitize_orientdb_vars(var) hash[var_name] = sanitize_orientdb_values(self.instance_variable_get(var)) end - hash.delete('id') + delete_unused_vars hash + end - excluded_orientdb_properties.each { |property| hash.delete(property.to_s) } + def excluded_orientdb_properties + [] + end - # TODO: find a better way to ignore variables from ActiveModel - hash.delete("validation_context") - hash.delete("errors") + private + + def delete_unused_vars(hash) + delete_vars_from_hash ['id', 'validation_context', 'errors'], hash + delete_vars_from_hash excluded_orientdb_properties, hash hash end - def excluded_orientdb_properties - [] + def delete_vars_from_hash(vars=[], hash) + vars.each { |property| hash.delete(property.to_s) } end end \ No newline at end of file -- GitLab