teamcity-ruby-client icon indicating copy to clipboard operation
teamcity-ruby-client copied to clipboard

Consistent method arguments

Open jperry opened this issue 12 years ago • 5 comments

I wanted to start a conversation around consistent method arguments and get opinions on what flavor folks like best. I'll list a few to start, suggestions are welcome.

Any methods that only require one argument should be using a hash, see example

Hash parameters

method(id: 'value', param2: 'value')

single parameters

method(id, param2)

Parameters using blocks

method do |options|
  options.id = 'value'
  options.param2 = 'value'
end


jperry avatar May 03 '13 01:05 jperry

Sorry I was unclear, I meant just for building the request string to send to the get method. I totally agree that sending the complete hash to the method is appropriate.

myanaros avatar Jul 15 '13 17:07 myanaros

@myanaros - thanks for your response, I will probably review all places that aren't using the hash approach and convert them over, this will probably be a major version upgrade since it will break anyone using the old api. I may support both as a way to allow folks to migrate over. I hope this hasn't caused too much confusion =)

jperry avatar Jul 15 '13 18:07 jperry

It all makes sense, this gem has saved me more time than I can imagine. I look forward to the new version!

myanaros avatar Jul 15 '13 18:07 myanaros

Thanks, glad to hear the gem has been helping you out.

jperry avatar Jul 15 '13 18:07 jperry

@myanaros - Just released 0.4.0

jperry avatar Jul 15 '13 19:07 jperry