Skip to content

Commit 9d94183

Browse files
committed
Rename option to convert_body?
- The transform_body method was extract from http_request during thicolares@c8144ac - Now, the only possible conversion is to_json - Then, I rename it to make it not related anyway to the extracted method transform_body
1 parent ca5d7c5 commit 9d94183

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

lib/meilisearch/http_request.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def initialize(url, api_key = nil, options = {})
1616
timeout: 1,
1717
max_retries: 0,
1818
headers: build_default_options_headers(api_key),
19-
transform_body?: true
19+
convert_body?: true
2020
}, options)
2121
end
2222

@@ -96,7 +96,7 @@ def send_request(http_method, relative_path, query_params: nil, body: nil, optio
9696
end
9797

9898
def http_config(query_params, body, options)
99-
body = body.to_json if options[:transform_body?] == true
99+
body = body.to_json if options[:convert_body?] == true
100100
{
101101
headers: options[:headers],
102102
query: query_params,

lib/meilisearch/index.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,21 +85,21 @@ def add_documents!(documents, primary_key = nil)
8585
alias add_or_replace_documents! add_documents!
8686

8787
def add_documents_json(documents, primary_key = nil)
88-
options = { headers: { 'Content-Type' => 'application/json' }, transform_body?: false }
88+
options = { headers: { 'Content-Type' => 'application/json' }, convert_body?: false }
8989
http_post "/indexes/#{@uid}/documents", documents, { primaryKey: primary_key }.compact, options
9090
end
9191
alias replace_documents_json add_documents_json
9292
alias add_or_replace_documents_json add_documents_json
9393

9494
def add_documents_ndjson(documents, primary_key = nil)
95-
options = { headers: { 'Content-Type' => 'application/x-ndjson' }, transform_body?: false }
95+
options = { headers: { 'Content-Type' => 'application/x-ndjson' }, convert_body?: false }
9696
http_post "/indexes/#{@uid}/documents", documents, { primaryKey: primary_key }.compact, options
9797
end
9898
alias replace_documents_ndjson add_documents_ndjson
9999
alias add_or_replace_documents_ndjson add_documents_ndjson
100100

101101
def add_documents_csv(documents, primary_key = nil)
102-
options = { headers: { 'Content-Type' => 'text/csv' }, transform_body?: false }
102+
options = { headers: { 'Content-Type' => 'text/csv' }, convert_body?: false }
103103
http_post "/indexes/#{@uid}/documents", documents, { primaryKey: primary_key }.compact, options
104104
end
105105
alias replace_documents_csv add_documents_csv

spec/meilisearch/index/base_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
},
9595
max_retries: 1,
9696
timeout: 2,
97-
transform_body?: true
97+
convert_body?: true
9898
})
9999
expect(MeiliSearch::Index).to receive(:get).with(
100100
"#{URL}/indexes/options",

0 commit comments

Comments
 (0)