lib/soapy_cake/client.rb in soapy_cake-1.26.0 vs lib/soapy_cake/client.rb in soapy_cake-2.0.0
- old
+ new
@@ -42,13 +42,12 @@
def fetch_opt(key, fallback = nil)
opts.fetch(key, ENV.fetch("CAKE_#{key.to_s.upcase}", fallback))
end
def check_write_enabled!(request)
- unless request.read_only? || write_enabled
- raise Error, 'Writes not enabled (pass write_enabled: true or set CAKE_WRITE_ENABLED=yes)'
- end
+ return if request.read_only? || write_enabled
+ raise Error, 'Writes not enabled (pass write_enabled: true or set CAKE_WRITE_ENABLED=yes)'
end
def with_retries(&block)
opts = { tries: retry_count + 1, on: [RateLimitError, SocketError], sleep: -> (n) { 3**n } }
Retryable.retryable(opts, &block)
@@ -61,10 +60,10 @@
def response_body(request)
request.opts[:response].presence || http_response(request)
end
def http_response(request)
- logger.info("soapy_cake:request #{request}") if logger
+ logger&.info("soapy_cake:request #{request}")
http_request = Net::HTTP::Post.new(request.path, HEADERS)
http_request.body = request.xml
response = perform_http_request(http_request)