How to signal “not yet implemented”?

In the initial writing of the new gem, I need to leave some method implementations empty (for implementation in the following)

Therefore, I would like to signal a "not implemented" exception

I am wondering if there are best practices or standard conventions specific to the Ruby language for coding this type of placeholder / exception.

ie: something like:

+47
ruby coding-style exception-handling conventions
Dec 02
source share
5 answers

You must raise NotImplementedError

raise NotImplementedError 

ruby-doc

+11
May 18 '16 at 8:18
source share

You can use todonotes-gem

There is documentation with some examples.

It does not implement the exception, but the registration mechanism and the possibility of temporary solutions.

+3
Dec 02
source share

It looks like the original answer that suggested raising NotImplementedError been removed. I will hack it: write the documentation.

Do not add code, just placeholder. You wouldn’t want people to code this API, so don’t even give them opportunities (you yourself turned it on). Instead, document the roadmap you are currently planning in class and / or README. Then open it so that it changes. Odds by the time you get around to solve any problem on the roadmap, you will have new thoughts about what is the right solution. I think this is the right course of action in any language / structure, but I think that Ruby, in particular, encourages us not to write code that you do not plan to execute.

+1
Mar 24 '16 at 18:16
source share

Do not mention unfulfilled methods in the documents or do not mention that they are not yet implemented. It's all.

-5
Dec 02 2018-12-12T00: 00Z
source share

Ruby will raise a NoMethodError for you anyway when calling a nonexistent method. This should be good enough for most cases.

-22
Dec 02
source share



All Articles