@@ -1037,55 +1037,6 @@ def exists
1037
1037
1038
1038
private
1039
1039
1040
- # Check the passed object to determine if it's an array
1041
- #
1042
- # @param object [Object]
1043
- #
1044
- def check_array ( object )
1045
- raise AlgoliaError , 'argument must be an array of objects' unless object . is_a? ( Array )
1046
- end
1047
-
1048
- # Check the passed object
1049
- #
1050
- # @param object [Object]
1051
- # @param in_array [Boolean] whether the object is an array or not
1052
- #
1053
- def check_object ( object , in_array = false )
1054
- case object
1055
- when Array
1056
- raise AlgoliaError , in_array ? 'argument must be an array of objects' : 'argument must not be an array'
1057
- when String , Integer , Float , TrueClass , FalseClass , NilClass
1058
- raise AlgoliaError , "argument must be an #{ 'array of' if in_array } object, got: #{ object . inspect } "
1059
- end
1060
- end
1061
-
1062
- # Check if passed object has a objectID
1063
- #
1064
- # @param object [Object]
1065
- # @param object_id [String]
1066
- #
1067
- def get_object_id ( object , object_id = nil )
1068
- check_object ( object )
1069
- object_id ||= object [ :objectID ] || object [ 'objectID' ]
1070
- raise AlgoliaError , "Missing 'objectID'" if object_id . nil?
1071
- object_id
1072
- end
1073
-
1074
- # Build a batch request
1075
- #
1076
- # @param action [String] action to perform on the engine
1077
- # @param objects [Array] objects on which build the action
1078
- # @param with_object_id [Boolean] if set to true, check if each object has an objectID set
1079
- #
1080
- def chunk ( action , objects , with_object_id = false )
1081
- objects . map do |object |
1082
- check_object ( object , true )
1083
- request = { action : action , body : object }
1084
- request [ :objectID ] = get_object_id ( object ) . to_s if with_object_id
1085
- request
1086
- end
1087
- end
1088
-
1089
1040
def raw_batch ( requests , opts )
1090
1041
@transporter . write ( :POST , path_encode ( '/1/indexes/%s/batch' , @name ) , { requests : requests } , opts )
1091
1042
end
0 commit comments