From 65167b459b0336ac4382b1d9ffb18ae41e124554 Mon Sep 17 00:00:00 2001
From: Mauricio Giacomini Girardello <mauriciogiacomini4@gmail.com>
Date: Wed, 18 Nov 2015 16:06:04 -0200
Subject: [PATCH] change OrientDb::Base#build_hash implementation

---
 app/repositories/orient_db/base.rb | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/app/repositories/orient_db/base.rb b/app/repositories/orient_db/base.rb
index 394b8857..4d1016f3 100644
--- a/app/repositories/orient_db/base.rb
+++ b/app/repositories/orient_db/base.rb
@@ -44,19 +44,12 @@ class OrientDb::Base
     end
   end
 
+  protected
+
   # Take the object and make a hash in the OrientDB format.
   # Used to create a document.
   def build_hash(object)
-    hash = {'@class' => odb_class}
-    object.instance_variables.each do |var|
-      var_name = sanitize_orientdb_vars(var)
-      hash[var_name] = sanitize_orientdb_values(object.instance_variable_get(var))
-    end
-    hash.delete('id')
-    # TODO: find a better way to ignore variables from ActiveModel
-    hash.delete("validation_context")
-    hash.delete("errors")
-    hash
+    object.to_orientdb_hash
   end
 
   def build_objects(hash=[])
@@ -71,8 +64,6 @@ class OrientDb::Base
     raise NoMethodError, "You must implement this method"
   end
 
-  protected
-
   def accepted_properties
     raise NoMethodError, "You must implement this method"
   end
-- 
GitLab