diff --git a/app/models/concerns/orient_db_serializable.rb b/app/models/concerns/orient_db_serializable.rb new file mode 100644 index 0000000000000000000000000000000000000000..b7d626084d539d333cff6b01fa8eca2b960633e6 --- /dev/null +++ b/app/models/concerns/orient_db_serializable.rb @@ -0,0 +1,25 @@ +module OrientDbSerializable + extend ActiveSupport::Concern + include OrientDb::Methods::SanitizableMethods + + def to_orientdb_hash + hash = {'@class' => self.class.to_s} + self.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') + + excluded_orientdb_properties.each do |property| + hash.delete(property.to_s) + end + + # TODO: find a better way to ignore variables from ActiveModel + hash.delete("validation_context") + hash.delete("errors") + hash + end + + def excluded_orientdb_properties; end + +end \ No newline at end of file