4

Is there a convention to indicate that a parameter in YARD style documentation is only used for its "truthiness" status, that is you only want to know if it's false or nil or is truthy?

What is typically put in place of Truthy in the following?

# @param [String] name
# @param [Truthy] admin_status 
def create_user(name, admin_status)
  # code goes here
end

The closest I can find in the documentation is Boolean, which isn't really what I want.

Andrew Grimm
  • 78,473
  • 57
  • 200
  • 338

2 Answers2

6

Using anything other than Boolean would imply that you're doing some sort of special handling, like interpreting 0 as false or something less literal than true/false checking.

You can see the convention used in the YARD docs where Boolean represents both the TrueClass and FalseClass types. This type does not exist in Ruby, however.

BinaryButterfly
  • 18,137
  • 13
  • 50
  • 91
tadman
  • 208,517
  • 23
  • 234
  • 262
0

Is there a convention to indicate that a parameter in YARD style documentation is only used for its "truthiness" status

No. Below might be a workaround that's pretty close to what you requested:

# @param [Object] admin_status only used for its "truthiness" status

or

# @param [Object] admin_status check if it is false/nil/truthy

In other words, rely on param comment and accept anything as a type(therefore Object).

BinaryButterfly
  • 18,137
  • 13
  • 50
  • 91