Skip to content

Commit d713720

Browse files
author
Montana Flynn
committed
Fix & refactor custom methods
1 parent baa3158 commit d713720

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

src/targets/ruby/native.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,12 @@ module.exports = function (source, options) {
1313
// and if doesn't exist then we build a custom class for it
1414
var method = source.method.toUpperCase()
1515
var methods = ['GET', 'POST', 'HEAD', 'DELETE', 'PATCH', 'PUT', 'OPTIONS', 'COPY', 'LOCK', 'UNLOCK', 'MOVE', 'TRACE']
16-
method = method.toLowerCase()
17-
method = method.charAt(0).toUpperCase() + method.substring(1)
16+
var capMethod = method.charAt(0) + method.substring(1).toLowerCase()
1817
if (methods.indexOf(this.source.method.toLowerCase()) === 0) {
19-
var hasBody = self.source.postData.text ? 'true' : 'false'
20-
code.push('class Net::HTTP::Checkout < Net::HTTPRequest')
21-
code.push(util.format(' METHOD = \'%s\'', method))
22-
code.push(util.format(' REQUEST_HAS_BODY = \'%s\'', hasBody))
18+
code.push('class Net::HTTP::%s < Net::HTTPRequest')
19+
code.push(util.format('class Net::HTTP::%s < Net::HTTPRequest', capMethod))
20+
code.push(util.format(' METHOD = \'%s\'', method.toUpperCase()))
21+
code.push(util.format(' REQUEST_HAS_BODY = \'%s\'', self.source.postData.text ? 'true' : 'false'))
2322
code.push(' RESPONSE_HAS_BODY = true')
2423
code.push('end')
2524
code.push(null)
@@ -38,7 +37,7 @@ module.exports = function (source, options) {
3837

3938
code.push(null)
4039

41-
code.push(util.format('request = Net::HTTP::%s.new(url)', method))
40+
code.push(util.format('request = Net::HTTP::%s.new(url)', capMethod))
4241

4342
var headers = Object.keys(self.source.allHeaders)
4443
if (headers.length) {

0 commit comments

Comments
 (0)