I have an ActiveRecord class similar to this:
class User < ActiveRecord::Base
# How do I document this?
enum status [:registering, :active, :suspended, :deleted]
end
status
attribute is used to build a state machine. How do I document that line of code using yard? The documentation needs to contain explanation of status
attribute and all it's possible states.
Just list all options as comma separated list.
class User < ActiveRecord::Base
# @!attribute [rw] status
# @return [:registering, :active, :suspended, :deleted]
enum status [:registering, :active, :suspended, :deleted]
end
If you are not sure about type definition, you may consult with YARD Type Parser:
class User < ActiveRecord::Base
# @attr [Enumerable<Symbol>] status
enum status [:registering, :active, :suspended, :deleted]
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With