Skip to content

Commit 1b03f73

Browse files
committed
Fix and rename Models namespace
1 parent c5a8e92 commit 1b03f73

File tree

5 files changed

+47
-47
lines changed

5 files changed

+47
-47
lines changed

lib/meilisearch/client.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def swap_indexes(*options)
1717
mapped_array = options.map { |arr| { indexes: arr } }
1818

1919
response = http_post '/swap-indexes', mapped_array
20-
MeiliSearch::Model::Task.new(response, task_endpoint)
20+
Models::Task.new(response, task_endpoint)
2121
end
2222

2323
def indexes(options = {})
@@ -38,7 +38,7 @@ def create_index(index_uid, options = {})
3838

3939
response = http_post '/indexes', body
4040

41-
Model::Task.new(response, task_endpoint)
41+
Models::Task.new(response, task_endpoint)
4242
end
4343

4444
# Synchronous version of create_index.
@@ -126,7 +126,7 @@ def stats
126126

127127
def create_dump
128128
response = http_post '/dumps'
129-
MeiliSearch::Model::Task.new(response, task_endpoint)
129+
Models::Task.new(response, task_endpoint)
130130
end
131131

132132
### SNAPSHOTS

lib/meilisearch/index.rb

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ def fetch_raw_info
3131

3232
def update(body)
3333
response = http_patch indexes_path(id: @uid), Utils.transform_attributes(body)
34-
MeiliSearch::Model::Task.new(response, task_endpoint)
34+
Models::Task.new(response, task_endpoint)
3535
end
3636

3737
alias update_index update
3838

3939
def delete
4040
response = http_delete indexes_path(id: @uid)
41-
MeiliSearch::Model::Task.new(response, task_endpoint)
41+
Models::Task.new(response, task_endpoint)
4242
end
4343
alias delete_index delete
4444

@@ -90,7 +90,7 @@ def add_documents(documents, primary_key = nil)
9090
documents = [documents] if documents.is_a?(Hash)
9191
response = http_post "/indexes/#{@uid}/documents", documents, { primaryKey: primary_key }.compact
9292

93-
Model::Task.new(response, task_endpoint)
93+
Models::Task.new(response, task_endpoint)
9494
end
9595
alias replace_documents add_documents
9696
alias add_or_replace_documents add_documents
@@ -110,7 +110,7 @@ def add_documents_json(documents, primary_key = nil)
110110
options = { convert_body?: false }
111111
response = http_post "/indexes/#{@uid}/documents", documents, { primaryKey: primary_key }.compact, options
112112

113-
Model::Task.new(response, task_endpoint)
113+
Models::Task.new(response, task_endpoint)
114114
end
115115
alias replace_documents_json add_documents_json
116116
alias add_or_replace_documents_json add_documents_json
@@ -119,7 +119,7 @@ def add_documents_ndjson(documents, primary_key = nil)
119119
options = { headers: { 'Content-Type' => 'application/x-ndjson' }, convert_body?: false }
120120
response = http_post "/indexes/#{@uid}/documents", documents, { primaryKey: primary_key }.compact, options
121121

122-
Model::Task.new(response, task_endpoint)
122+
Models::Task.new(response, task_endpoint)
123123
end
124124
alias replace_documents_ndjson add_documents_ndjson
125125
alias add_or_replace_documents_ndjson add_documents_ndjson
@@ -132,7 +132,7 @@ def add_documents_csv(documents, primary_key = nil, delimiter = nil)
132132
csvDelimiter: delimiter
133133
}.compact, options
134134

135-
Model::Task.new(response, task_endpoint)
135+
Models::Task.new(response, task_endpoint)
136136
end
137137
alias replace_documents_csv add_documents_csv
138138
alias add_or_replace_documents_csv add_documents_csv
@@ -141,7 +141,7 @@ def update_documents(documents, primary_key = nil)
141141
documents = [documents] if documents.is_a?(Hash)
142142
response = http_put "/indexes/#{@uid}/documents", documents, { primaryKey: primary_key }.compact
143143

144-
Model::Task.new(response, task_endpoint)
144+
Models::Task.new(response, task_endpoint)
145145
end
146146
alias add_or_update_documents update_documents
147147

@@ -204,7 +204,7 @@ def delete_documents(options = {})
204204
http_post "/indexes/#{@uid}/documents/delete-batch", options
205205
end
206206

207-
Model::Task.new(response, task_endpoint)
207+
Models::Task.new(response, task_endpoint)
208208
end
209209
end
210210
alias delete_multiple_documents delete_documents
@@ -223,7 +223,7 @@ def delete_document(document_id)
223223
encode_document = URI.encode_www_form_component(document_id)
224224
response = http_delete "/indexes/#{@uid}/documents/#{encode_document}"
225225

226-
Model::Task.new(response, task_endpoint)
226+
Models::Task.new(response, task_endpoint)
227227
end
228228
alias delete_one_document delete_document
229229

@@ -239,7 +239,7 @@ def delete_document!(document_id)
239239

240240
def delete_all_documents
241241
response = http_delete "/indexes/#{@uid}/documents"
242-
Model::Task.new(response, task_endpoint)
242+
Models::Task.new(response, task_endpoint)
243243
end
244244

245245
def delete_all_documents!
@@ -322,13 +322,13 @@ def settings
322322

323323
def update_settings(settings)
324324
response = http_patch "/indexes/#{@uid}/settings", Utils.transform_attributes(settings)
325-
MeiliSearch::Model::Task.new(response, task_endpoint)
325+
Models::Task.new(response, task_endpoint)
326326
end
327327
alias settings= update_settings
328328

329329
def reset_settings
330330
response = http_delete "/indexes/#{@uid}/settings"
331-
MeiliSearch::Model::Task.new(response, task_endpoint)
331+
Models::Task.new(response, task_endpoint)
332332
end
333333

334334
### SETTINGS - RANKING RULES
@@ -340,13 +340,13 @@ def ranking_rules
340340

341341
def update_ranking_rules(ranking_rules)
342342
response = http_put "/indexes/#{@uid}/settings/ranking-rules", ranking_rules
343-
MeiliSearch::Model::Task.new(response, task_endpoint)
343+
Models::Task.new(response, task_endpoint)
344344
end
345345
alias ranking_rules= update_ranking_rules
346346

347347
def reset_ranking_rules
348348
response = http_delete "/indexes/#{@uid}/settings/ranking-rules"
349-
MeiliSearch::Model::Task.new(response, task_endpoint)
349+
Models::Task.new(response, task_endpoint)
350350
end
351351

352352
### SETTINGS - SYNONYMS
@@ -358,13 +358,13 @@ def synonyms
358358

359359
def update_synonyms(synonyms)
360360
response = http_put "/indexes/#{@uid}/settings/synonyms", synonyms
361-
MeiliSearch::Model::Task.new(response, task_endpoint)
361+
Models::Task.new(response, task_endpoint)
362362
end
363363
alias synonyms= update_synonyms
364364

365365
def reset_synonyms
366366
response = http_delete "/indexes/#{@uid}/settings/synonyms"
367-
MeiliSearch::Model::Task.new(response, task_endpoint)
367+
Models::Task.new(response, task_endpoint)
368368
end
369369

370370
### SETTINGS - STOP-WORDS
@@ -377,13 +377,13 @@ def stop_words
377377
def update_stop_words(stop_words)
378378
body = stop_words.nil? || stop_words.is_a?(Array) ? stop_words : [stop_words]
379379
response = http_put "/indexes/#{@uid}/settings/stop-words", body
380-
MeiliSearch::Model::Task.new(response, task_endpoint)
380+
Models::Task.new(response, task_endpoint)
381381
end
382382
alias stop_words= update_stop_words
383383

384384
def reset_stop_words
385385
response = http_delete "/indexes/#{@uid}/settings/stop-words"
386-
MeiliSearch::Model::Task.new(response, task_endpoint)
386+
Models::Task.new(response, task_endpoint)
387387
end
388388

389389
### SETTINGS - DINSTINCT ATTRIBUTE
@@ -395,13 +395,13 @@ def distinct_attribute
395395

396396
def update_distinct_attribute(distinct_attribute)
397397
response = http_put "/indexes/#{@uid}/settings/distinct-attribute", distinct_attribute
398-
MeiliSearch::Model::Task.new(response, task_endpoint)
398+
Models::Task.new(response, task_endpoint)
399399
end
400400
alias distinct_attribute= update_distinct_attribute
401401

402402
def reset_distinct_attribute
403403
response = http_delete "/indexes/#{@uid}/settings/distinct-attribute"
404-
MeiliSearch::Model::Task.new(response, task_endpoint)
404+
Models::Task.new(response, task_endpoint)
405405
end
406406

407407
### SETTINGS - SEARCHABLE ATTRIBUTES
@@ -413,13 +413,13 @@ def searchable_attributes
413413

414414
def update_searchable_attributes(searchable_attributes)
415415
response = http_put "/indexes/#{@uid}/settings/searchable-attributes", searchable_attributes
416-
MeiliSearch::Model::Task.new(response, task_endpoint)
416+
Models::Task.new(response, task_endpoint)
417417
end
418418
alias searchable_attributes= update_searchable_attributes
419419

420420
def reset_searchable_attributes
421421
response = http_delete "/indexes/#{@uid}/settings/searchable-attributes"
422-
MeiliSearch::Model::Task.new(response, task_endpoint)
422+
Models::Task.new(response, task_endpoint)
423423
end
424424

425425
### SETTINGS - DISPLAYED ATTRIBUTES
@@ -431,13 +431,13 @@ def displayed_attributes
431431

432432
def update_displayed_attributes(displayed_attributes)
433433
response = http_put "/indexes/#{@uid}/settings/displayed-attributes", displayed_attributes
434-
MeiliSearch::Model::Task.new(response, task_endpoint)
434+
Models::Task.new(response, task_endpoint)
435435
end
436436
alias displayed_attributes= update_displayed_attributes
437437

438438
def reset_displayed_attributes
439439
response = http_delete "/indexes/#{@uid}/settings/displayed-attributes"
440-
MeiliSearch::Model::Task.new(response, task_endpoint)
440+
Models::Task.new(response, task_endpoint)
441441
end
442442

443443
### SETTINGS - FILTERABLE ATTRIBUTES
@@ -449,13 +449,13 @@ def filterable_attributes
449449

450450
def update_filterable_attributes(filterable_attributes)
451451
response = http_put "/indexes/#{@uid}/settings/filterable-attributes", filterable_attributes
452-
Model::Task.new(response, task_endpoint)
452+
Models::Task.new(response, task_endpoint)
453453
end
454454
alias filterable_attributes= update_filterable_attributes
455455

456456
def reset_filterable_attributes
457457
response = http_delete "/indexes/#{@uid}/settings/filterable-attributes"
458-
MeiliSearch::Model::Task.new(response, task_endpoint)
458+
Models::Task.new(response, task_endpoint)
459459
end
460460

461461
### SETTINGS - SORTABLE ATTRIBUTES
@@ -467,13 +467,13 @@ def sortable_attributes
467467

468468
def update_sortable_attributes(sortable_attributes)
469469
response = http_put "/indexes/#{@uid}/settings/sortable-attributes", sortable_attributes
470-
MeiliSearch::Model::Task.new(response, task_endpoint)
470+
Models::Task.new(response, task_endpoint)
471471
end
472472
alias sortable_attributes= update_sortable_attributes
473473

474474
def reset_sortable_attributes
475475
response = http_delete "/indexes/#{@uid}/settings/sortable-attributes"
476-
MeiliSearch::Model::Task.new(response, task_endpoint)
476+
Models::Task.new(response, task_endpoint)
477477
end
478478

479479
### SETTINGS - PAGINATION
@@ -485,13 +485,13 @@ def pagination
485485

486486
def update_pagination(pagination)
487487
response = http_patch "/indexes/#{@uid}/settings/pagination", pagination
488-
MeiliSearch::Model::Task.new(response, task_endpoint)
488+
Models::Task.new(response, task_endpoint)
489489
end
490490
alias pagination= update_sortable_attributes
491491

492492
def reset_pagination
493493
response = http_delete "/indexes/#{@uid}/settings/pagination"
494-
MeiliSearch::Model::Task.new(response, task_endpoint)
494+
Models::Task.new(response, task_endpoint)
495495
end
496496

497497
def typo_tolerance
@@ -502,13 +502,13 @@ def typo_tolerance
502502
def update_typo_tolerance(typo_tolerance_attributes)
503503
attributes = Utils.transform_attributes(typo_tolerance_attributes)
504504
response = http_patch("/indexes/#{@uid}/settings/typo-tolerance", attributes)
505-
MeiliSearch::Model::Task.new(response, task_endpoint)
505+
Models::Task.new(response, task_endpoint)
506506
end
507507
alias typo_tolerance= update_typo_tolerance
508508

509509
def reset_typo_tolerance
510510
response = http_delete("/indexes/#{@uid}/settings/typo-tolerance")
511-
MeiliSearch::Model::Task.new(response, task_endpoint)
511+
Models::Task.new(response, task_endpoint)
512512
end
513513

514514
def faceting
@@ -519,13 +519,13 @@ def faceting
519519
def update_faceting(faceting_attributes)
520520
attributes = Utils.transform_attributes(faceting_attributes)
521521
response = http_patch("/indexes/#{@uid}/settings/faceting", attributes)
522-
MeiliSearch::Model::Task.new(response, task_endpoint)
522+
Models::Task.new(response, task_endpoint)
523523
end
524524
alias faceting= update_faceting
525525

526526
def reset_faceting
527527
response = http_delete("/indexes/#{@uid}/settings/faceting")
528-
MeiliSearch::Model::Task.new(response, task_endpoint)
528+
Models::Task.new(response, task_endpoint)
529529
end
530530

531531
### SETTINGS - DICTIONARY
@@ -537,12 +537,12 @@ def dictionary
537537
def update_dictionary(dictionary_attributes)
538538
attributes = Utils.transform_attributes(dictionary_attributes)
539539
response = http_put("/indexes/#{@uid}/settings/dictionary", attributes)
540-
MeiliSearch::Model::Task.new(response, task_endpoint)
540+
Models::Task.new(response, task_endpoint)
541541
end
542542

543543
def reset_dictionary
544544
response = http_delete("/indexes/#{@uid}/settings/dictionary")
545-
MeiliSearch::Model::Task.new(response, task_endpoint)
545+
Models::Task.new(response, task_endpoint)
546546
end
547547
### SETTINGS - SEPARATOR TOKENS
548548

@@ -553,12 +553,12 @@ def separator_tokens
553553
def update_separator_tokens(separator_tokens_attributes)
554554
attributes = Utils.transform_attributes(separator_tokens_attributes)
555555
response = http_put("/indexes/#{@uid}/settings/separator-tokens", attributes)
556-
MeiliSearch::Model::Task.new(response, task_endpoint)
556+
Models::Task.new(response, task_endpoint)
557557
end
558558

559559
def reset_separator_tokens
560560
response = http_delete("/indexes/#{@uid}/settings/separator-tokens")
561-
MeiliSearch::Model::Task.new(response, task_endpoint)
561+
Models::Task.new(response, task_endpoint)
562562
end
563563

564564
### SETTINGS - NON SEPARATOR TOKENS
@@ -570,12 +570,12 @@ def non_separator_tokens
570570
def update_non_separator_tokens(non_separator_tokens_attributes)
571571
attributes = Utils.transform_attributes(non_separator_tokens_attributes)
572572
response = http_put("/indexes/#{@uid}/settings/non-separator-tokens", attributes)
573-
MeiliSearch::Model::Task.new(response, task_endpoint)
573+
Models::Task.new(response, task_endpoint)
574574
end
575575

576576
def reset_non_separator_tokens
577577
response = http_delete("/indexes/#{@uid}/settings/non-separator-tokens")
578-
MeiliSearch::Model::Task.new(response, task_endpoint)
578+
Models::Task.new(response, task_endpoint)
579579
end
580580

581581
### SETTINGS - PROXIMITY PRECISION

lib/meilisearch/models/task.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
require 'forwardable'
44

55
module MeiliSearch
6-
module Model
6+
module Models
77
class Task
88
extend Forwardable
99

spec/meilisearch/index/documents_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@
121121

122122
it 'adds documents in a batch (as a array of documents)' do
123123
tasks = index.add_documents_in_batches(documents, 5)
124-
expect(tasks).to contain_exactly(a_kind_of(MeiliSearch::Model::Task),
125-
a_kind_of(MeiliSearch::Model::Task))
124+
expect(tasks).to contain_exactly(a_kind_of(MeiliSearch::Models::Task),
125+
a_kind_of(MeiliSearch::Models::Task))
126126
tasks.each(&:await)
127127
expect(index.documents['results']).to contain_exactly(*documents_with_string_keys)
128128
end

spec/meilisearch/models/task_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
describe MeiliSearch::Model::Task do
3+
describe MeiliSearch::Models::Task do
44
let(:new_index_uid) { random_uid }
55
let(:task_hash) { client.http_post '/indexes', { 'uid' => new_index_uid } }
66
let(:endpoint) { MeiliSearch::Task.new(URL, MASTER_KEY, client.options) }

0 commit comments

Comments
 (0)